Prev: BA22 Up: Map Next: BAAB
BA9B: Wait For Key Press
Used by the routines at GameOver and GameCompleted.
Waits until any key is pressed or until a time limit passes. The time is B times the time that it takes to count FFFF down to zero.
Input
B Number of times to count down
Output
F Zero flag clear if a key was pressed
Wait for a key, or count down 10000 times.
WaitForKeyPress BA9B LD HL,$0000 Set the counter to zero, to count 10000 times.
WaitForKeyPress_Wait BA9E XOR A Select all the half-rows of the keyboard.
BA9F CALL ReadKeyboardPort Read the keyboard.
BAA2 RET NZ Return if a key is pressed.
BAA3 DEC HL Decrease the counter.
BAA4 LD A,H Check whether the counter has reached zero.
BAA5 OR L
BAA6 JR NZ,WaitForKeyPress_Wait Jump to WaitForKeyPress_Wait until the counter is zero.
BAA8 DJNZ WaitForKeyPress_Wait Jump to WaitForKeyPress_Wait until the time limit has passed.
BAAA RET Return.
View the equivalent code in;
Prev: BA22 Up: Map Next: BAAB