Prev: 722E Up: Map Next: 728B
7249: Input: Wait For A Key
Used by the routine at ReadTheInputLine.
Counts down the input delay while polling the keyboard. A key raises the next delay by 01F4, up to 0BB8, and is returned. If the delay runs out, 7291 is printed into the buffer, ENTER is returned, and the next delay is cleared.
Input_WaitForAKey 7249 PUSH HL Read the input delay.
724A LD HL,($B714)
Input_WaitForAKey_Poll 724D CALL GetKey Poll the keyboard.
7250 AND A Jump to Input_WaitForAKey_AddToTheDelay if a key is waiting.
7251 JR NZ,Input_WaitForAKey_AddToTheDelay
7253 DEC HL Loop back to Input_WaitForAKey_Poll to keep polling until the delay runs out.
7254 LD A,H
7255 OR L
7256 JR NZ,Input_WaitForAKey_Poll
7258 POP HL Rub out the characters typed so far.
7259 PUSH HL
725A CALL Input_RubOutCharacters
725D LD DE,$7291 Point at the letters W, A, I, T.
7260 LD B,$04 Four letters.
Input_WaitForAKey_Wait 7262 LD A,(DE) Store the next letter of 7291 in the input buffer.
7263 LD (HL),A
7264 INC HL
7265 INC DE
7266 CALL Print_Character Print that letter.
7269 DJNZ Input_WaitForAKey_Wait Loop back to Input_WaitForAKey_Wait until 7291 is done.
726B EX (SP),HL Remember the pointer after 7291, and prepare ENTER. The next delay is FE0C plus 01F4, which is zero.
726C LD B,$7C
726E LD A,$0D
7270 LD HL,$FE0C
Input_WaitForAKey_AddToTheDelay 7273 PUSH AF Add 01F4 to the delay. A key raises the current delay; the timeout path adds it to zero.
7274 XOR A
7275 LD DE,$01F4
7278 ADC HL,DE
727A LD DE,$0BB8 The cap is 0BB8.
727D JR C,Input_WaitForAKey_Cap Jump to Input_WaitForAKey_Cap if the sum overflowed, and use the cap.
727F CALL Input_CompareTwoTotals Call Input_CompareTwoTotals to compare the delay with the cap.
7282 JR C,Input_WaitForAKey_Store Jump to Input_WaitForAKey_Store if the delay is still under the cap.
Input_WaitForAKey_Cap 7284 EX DE,HL Use the cap instead.
Input_WaitForAKey_Store 7285 LD ($B714),HL Store the next input delay.
7288 POP AF Restore AF and HL from the stack.
7289 POP HL
728A RET Return.
Prev: 722E Up: Map Next: 728B