.WaitForSpaceReturn STA G \ Store A in G so we can check the value of bit 7 below LDX #30 \ Print token 30 ("PRESS SPACE BAR TO CONTINUE" in cyan JSR PrintToken \ at column 5, row 24) .wait1 LDX #&9D \ Scan the keyboard to see if SPACE is being pressed JSR ScanKeyboard BEQ wait1 \ If SPACE is being pressed, loop back to wait1 until \ it is released .wait2 LDX #&9D \ Scan the keyboard to see if SPACE is being pressed JSR ScanKeyboard BEQ wait3 \ If SPACE is being pressed, jump to wait3 to return \ from the subroutine JSR CheckRestartKeys \ Check whether the restart keys are being pressed, and \ if they are, restart the game (the restart keys are \ SHIFT and right arrow) BIT G \ If bit 7 of G is clear, jump back to wait2 to wait for BPL wait2 \ SPACE to be pressed LDX #&B6 \ Scan the keyboard to see if RETURN is being pressed JSR ScanKeyboard BNE wait2 \ If RETURN is not being pressed, jump back to wait2 to \ wait for RETURN is being pressed LSR G \ Clear bit 7 of G .wait3 RTS \ Return from the subroutineName: WaitForSpaceReturn [Show more] Type: Subroutine Category: Keyboard Summary: Print a prompt, wait for the SPACE key to be released, and wait for either SPACE or RETURN to be pressedContext: See this subroutine in context in the source code References: This subroutine is called as follows: * PrintDriverTable calls WaitForSpaceReturn
Arguments: A Determines the key to wait for: * Bit 7 clear = wait for SPACE to be pressed * Bit 7 set = wait for SPACE or RETURN to be pressed
Returns: G If bit 7 was set on entry, then it is cleared if RETURN was pressed, but remains set if SPACE was pressed
[X]
Subroutine CheckRestartKeys (category: Keyboard)
If the restart keys are being pressed, restart the game
[X]
Subroutine PrintToken (category: Text)
Print a recursive token
[X]
Subroutine ScanKeyboard (category: Keyboard)
Scan the keyboard for a specific key press
[X]
Label wait1 is local to this routine
[X]
Label wait2 is local to this routine
[X]
Label wait3 is local to this routine