Prev: 722E Up: Map Next: 728B
7249: Wait for a key, or type WAIT when none comes
Used by the routine at READ_LINE.
Counts down from PATIENCE while it scans the keyboard, and returns the first new key. If the count runs out first it does something rather nice: it clears the line, copies the four letters at WAIT_TEXT -- WAIT -- into it, prints them, and returns a carriage return as though the player had pressed ENTER. So "time passes" is the game typing a command on your behalf, and the WAIT lines on screen that nobody typed are exactly that.
The keyboard scan reports only changes. A driver that stops the game with ENTER held and presses it again at the next prompt is not heard, because the release was never seen; hobbit_drive.py lets it scan with nothing held first.
Output
A The key
GET_KEY 7249 PUSH HL
724A LD HL,(PATIENCE) Scan until a new key, or until the patience in PATIENCE runs out
GET_KEY_0 724D CALL SCAN_KEYBOARD
7250 AND A
7251 JR NZ,GET_KEY_2
7253 DEC HL
7254 LD A,H
7255 OR L
7256 JR NZ,GET_KEY_0
7258 POP HL Out of patience: clear the line...
7259 PUSH HL
725A CALL RUB_OUT_LINE
725D LD DE,WAIT_TEXT ...type WAIT into it, printing each letter as a player would...
7260 LD B,$04
GET_KEY_1 7262 LD A,(DE)
7263 LD (HL),A
7264 INC HL
7265 INC DE
7266 CALL PRINT_CHAR
7269 DJNZ GET_KEY_1
726B EX (SP),HL ...and return as if ENTER had been pressed after it
726C LD B,$7C
726E LD A,$0D
7270 LD HL,$FE0C
GET_KEY_2 7273 PUSH AF The next wait is what was left of this one plus 500, at most 3000; after a timeout it is 3000 again
7274 XOR A
7275 LD DE,$01F4
7278 ADC HL,DE
727A LD DE,$0BB8
727D JR C,GET_KEY_3
727F CALL COMPARE_HL_DE
7282 JR C,GET_KEY_4
GET_KEY_3 7284 EX DE,HL
GET_KEY_4 7285 LD (PATIENCE),HL
7288 POP AF
7289 POP HL
728A RET
Prev: 722E Up: Map Next: 728B