Prev: B881 Up: Map Next: B8A9
B899: Wait for a key, or for a while
Used by the routines at GAME_ENDED and ARRIVAL_SCREEN.
Reads the whole keyboard B times 65536 times, and returns as soon as a key is down. At 95 T-states a read (counted from the instructions), B = 8 is about 14 seconds. Knight Lore's wait_key_poll.
Input
B how long to wait, in units of 65536 reads
Output
F NZ if a key was pressed
WAIT_KEY_OR_TIME B899 LD HL,$0000 the inner count
WAIT_KEY_OR_TIME_0 B89C XOR A any key: done
B89D CALL READ_KEYS
B8A0 RET NZ
B8A1 DEC HL the inner count
B8A2 LD A,H
B8A3 OR L
B8A4 JR NZ,WAIT_KEY_OR_TIME_0
B8A6 DJNZ WAIT_KEY_OR_TIME_0 the outer count
B8A8 RET
Prev: B881 Up: Map Next: B8A9