Prev: 26106 Up: Map Next: 26217
26116: Handler: User Input
Used by the routines at Handler_UnknownWord, GameLoop and ActionRead.
Handles keyboard input, tokenises commands and validates the vocabulary.
Prepare a blank command line.
Handler_UserInput 26116 CALL SetDefaultScreenPosition Call SetDefaultScreenPosition to park the cursor at the default position.
26119 LD HL,25183 Blank the command buffer with 50 spaces.
26122 LD A,32
26124 LD B,50
Handler_UserInput_Loop1 26126 LD (HL),A Write spaces through the command buffer.
26127 INC HL
26128 DJNZ Handler_UserInput_Loop1
Ask for a command.
26130 CALL PrintInputPrompt Call PrintInputPrompt to print the prompt.
26133 LD HL,25183 The next character is stored at the start of the command.
Read the next key.
Handler_UserInput_Loop2 26136 CALL GetUserInput Call GetUserInput to wait for a keypress.
26139 CP 12 Jump to Handler_UserInput_Step1 when DELETE (12) was pressed.
26141 JR Z,Handler_UserInput_Step1
26143 CP 13 Jump to Handler_UserInput_Step2 when ENTER (13) was pressed.
26145 JR Z,Handler_UserInput_Step2
26147 CP 32 Jump back to Handler_UserInput_Loop2 when the key is a control character.
26149 JR C,Handler_UserInput_Loop2
26151 EX DE,HL Jump back to Handler_UserInput_Loop2 when the command buffer is full.
26152 LD HL,25232
26155 AND A
26156 SBC HL,DE
26158 EX DE,HL
26159 JR Z,Handler_UserInput_Loop2
26161 LD (HL),A Store the character in the command buffer and print it.
26162 CALL SwitchToNormalScreenOutput
26165 CALL PrintCharacter
26168 INC HL
26169 JR Handler_UserInput_Loop2
The player pressed DELETE.
Handler_UserInput_Step1 26171 EX DE,HL Jump back to Handler_UserInput_Loop2 when there is nothing to delete.
26172 LD HL,25183
26175 AND A
26176 SBC HL,DE
26178 EX DE,HL
26179 JR Z,Handler_UserInput_Loop2
26181 PUSH HL Print   and rub out the last character.
26182 LD HL,25315
26185 CALL PrintString
26188 POP HL
26189 DEC HL
26190 LD (HL),32
26192 JR Handler_UserInput_Loop2
The player pressed ENTER.
Handler_UserInput_Step2 26194 LD (HL),A Store the terminator and echo the newline.
26195 CALL SwitchToNormalScreenOutput
26198 CALL PrintCharacter
26201 LD HL,25233 Point at the word tokens and prepare the empty marker (255).
26204 LD A,255
26206 LD B,10
Handler_UserInput_Loop3 26208 LD (HL),A Mark every word token as empty.
26209 INC HL
26210 DJNZ Handler_UserInput_Loop3
26212 LD HL,25183 Up to 10 words of the command are accepted.
26215 LD C,10
Prev: 26106 Up: Map Next: 26217