Prev: 28108 Up: Map Next: 28239
28118: Read The Input Line
Used by the routine at TurnReadAndTokeniseTheCommand.
Reads one line into the input buffer. Cursor keys become the compass letters, and a quote or full stop ends a word.
ReadTheInputLine 28118 LD HL,3000 Store 3000 in *46868.
28121 LD (46868),HL
Update the action countdown.
28124 LD A,1 Write 1 to *WaitCountdown and *46842.
28126 LD (46849),A
28129 LD (46842),A
Print the ">" prompt.
28132 LD A,62 Print '>'.
28134 CALL Print_Character
Print a space.
28137 LD A,32 Print a space.
28139 CALL Print_Character
28142 LD HL,28665 Point at the input buffer.
28145 LD B,128 Start the free-space count at 128.
ReadTheInputLine_Loop 28147 LD C,0 No characters have been rubbed out yet.
This entry point is used by the routine at Input_MapACursorKey.
Read the next key.
ReadTheInputLine_WaitForAKey 28149 CALL Input_WaitForAKey Call Input_WaitForAKey to wait for a key.
28152 BIT 7,B Jump to ReadTheInputLine_TestTheRubOutKey if bit 7 of the free-space count in B is clear.
28154 JR Z,ReadTheInputLine_TestTheRubOutKey
28156 CP 64 Jump to Input_MapACursorKey_ReadAnotherKeyWhenTheFlagIsSet when the character is 64.
28158 JP Z,Input_MapACursorKey_ReadAnotherKeyWhenTheFlagIsSet
ReadTheInputLine_TestTheRubOutKey 28161 BIT 0,C Call Input_MapACursorKey if bit 0 of C (set once a character has been rubbed out) is clear.
28163 CALL Z,Input_MapACursorKey
28166 LD C,1 Set the rubbed-out flag and jump to ReadTheInputLine_TestForABackspace unless the key is 24.
28168 CP 24
28170 JR NZ,ReadTheInputLine_TestForABackspace
Rub out the whole line.
28172 CALL Input_RubOutCharacters Call Input_RubOutCharacters to rub out characters.
28175 JR ReadTheInputLine_Loop Jump back to ReadTheInputLine_Loop to read the next character.
ReadTheInputLine_TestForABackspace 28177 CP 8 Jump to ReadTheInputLine_TestForALetter unless the key is 8.
28179 JR NZ,ReadTheInputLine_TestForALetter
28181 BIT 7,B Jump back to ReadTheInputLine_WaitForAKey if bit 7 of the free-space count in B is set.
28183 JR NZ,ReadTheInputLine_WaitForAKey
Print character 8.
28185 LD A,8 Print a backspace.
28187 CALL Print_Character
28190 INC B One more byte of the line is free.
28191 DEC HL Step back one byte through 28665.
28192 JR ReadTheInputLine_WaitForAKey Jump back to ReadTheInputLine_WaitForAKey to read the next key.
ReadTheInputLine_TestForALetter 28194 CP 64 Jump to ReadTheInputLine_RememberTheAcceptedKey if the key is not below 64.
28196 JR NC,ReadTheInputLine_RememberTheAcceptedKey
28198 CP 34 Jump to ReadTheInputLine_RememberTheAcceptedKey if the key is a quote.
28200 JR Z,ReadTheInputLine_RememberTheAcceptedKey
28202 CP 32 Jump to ReadTheInputLine_RememberTheAcceptedKey if the key is a space.
28204 JR Z,ReadTheInputLine_RememberTheAcceptedKey
28206 CP 13 Jump to ReadTheInputLine_RememberTheAcceptedKey if the key is ENTER.
28208 JR Z,ReadTheInputLine_RememberTheAcceptedKey
28210 CP 46 Jump to ReadTheInputLine_RememberTheAcceptedKey if the key is a full stop.
28212 JR Z,ReadTheInputLine_RememberTheAcceptedKey
28214 CP 44 Jump back to ReadTheInputLine_WaitForAKey if the key is not a comma.
28216 JR NZ,ReadTheInputLine_WaitForAKey
ReadTheInputLine_RememberTheAcceptedKey 28218 LD (46852),A Remember this key at 46852 so the next letter is capitalised.
28221 DEC B Jump to ReadTheInputLine_FinishWhenTheKeyIsEnter if the free-space count in B is zero.
28222 INC B
28223 JR Z,ReadTheInputLine_FinishWhenTheKeyIsEnter
Print the character in A.
28225 CALL Print_Character Call Print_Character to print one character.
28228 LD (HL),A Store it at 28665 and step on.
28229 INC HL
28230 DEC B One fewer byte of the line is free.
ReadTheInputLine_FinishWhenTheKeyIsEnter 28231 CP 13 Jump back to ReadTheInputLine_WaitForAKey if the key is not ENTER.
28233 JP NZ,ReadTheInputLine_WaitForAKey
28236 OR 1 Clear the zero flag so ENTER ends the line.
28238 RET Return.
View the equivalent code in;
Prev: 28108 Up: Map Next: 28239