![]() |
Routines |
| Prev: 26106 | Up: Map | Next: 26217 |
|
Read a line of text, then turn it into vocabulary tokens.
|
||||
|
Reset the cursor to the default text position.
|
||||
| Handler_UserInput | 26116 | CALL SetDefaultScreenPosition | Call SetDefaultScreenPosition. | |
|
Clear the command buffer.
|
||||
| 26119 | LD HL,25183 | Blank CommandBuffer 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 | |||
|
Print the ">" prompt.
|
||||
| 26130 | CALL PrintInputPrompt | Call PrintInputPrompt. | ||
|
Collect keypresses into the command buffer.
|
||||
| 26133 | LD HL,25183 | Start at the beginning of CommandBuffer. | ||
|
Wait for the next key.
|
||||
| Handler_UserInput_Loop2 | 26136 | CALL GetUserInput | Call GetUserInput. | |
|
DELETE rubs out a character. ENTER finishes the line. Any other control key is ignored.
|
||||
| 26139 | CP 12 | Jump to Handler_UserInput_Step1 if DELETE was pressed. | ||
| 26141 | JR Z,Handler_UserInput_Step1 | |||
| 26143 | CP 13 | Jump to Handler_UserInput_Step2 if ENTER was pressed. | ||
| 26145 | JR Z,Handler_UserInput_Step2 | |||
| 26147 | CP 32 | Jump back to Handler_UserInput_Loop2 when the key is below SPACE. | ||
| 26149 | JR C,Handler_UserInput_Loop2 | |||
|
Is the command buffer full?
|
||||
| 26151 | EX DE,HL | Jump back to Handler_UserInput_Loop2 once the pointer has reached the end of CommandBuffer. | ||
| 26152 | LD HL,25232 | |||
| 26155 | AND A | |||
| 26156 | SBC HL,DE | |||
| 26158 | EX DE,HL | |||
| 26159 | JR Z,Handler_UserInput_Loop2 | |||
|
The key is valid, so store it and print it.
|
||||
| 26161 | LD (HL),A | Write the key into the buffer and echo 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 the buffer is still empty. | |
| 26172 | LD HL,25183 | |||
| 26175 | AND A | |||
| 26176 | SBC HL,DE | |||
| 26178 | EX DE,HL | |||
| 26179 | JR Z,Handler_UserInput_Loop2 | |||
|
Rub the previous character off the screen.
Print " ".
|
||||
| 26181 | PUSH HL | Print " " and blank the previous 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, so close the command and clear the tokens.
|
||||
| Handler_UserInput_Step2 | 26194 | LD (HL),A | Store ENTER as the terminator and echo the newline. | |
| 26195 | CALL SwitchToNormalScreenOutput | |||
| 26198 | CALL PrintCharacter | |||
|
Initialise the word token buffer. Up to 10 vocabulary tokens are stored at UserInput_FirstToken; 255 marks an empty slot.
|
||||
| 26201 | LD HL,25233 | Point at UserInput_FirstToken and prepare the empty marker (255). | ||
| 26204 | LD A,255 | |||
| 26206 | LD B,10 | |||
| Handler_UserInput_Loop3 | 26208 | LD (HL),A | Write 255 into each of the 10 token slots. | |
| 26209 | INC HL | |||
| 26210 | DJNZ Handler_UserInput_Loop3 | |||
| 26212 | LD HL,25183 | Start at the command and allow 10 words, then fall into Parser_MatchInputWord. | ||
| 26215 | LD C,10 | |||
|
Continue on to Parser_MatchInputWord.
View the equivalent code in;
|
||||
| Prev: 26106 | Up: Map | Next: 26217 |