.CheckRestartKeys LDX #&FF \ Scan the keyboard to see if SHIFT is being pressed JSR ScanKeyboard BNE rest1 \ If SHIFT is not being pressed, jump to rest1 LDX #&86 \ Scan the keyboard to see if right arrow is being JSR ScanKeyboard \ pressed (if it is this will also set the C flag) BNE rest1 \ If right arrow is not being pressed, jump to rest1 BIT pressingShiftArrow \ If bit 7 of pressingShiftArrow is set, then we are BMI rest2 \ still pressing Shift-arrow from a previous restart, so \ jump to rest2 to return from the subroutine without \ anything doing \ If we get here then SHIFT-arrow is being pressed and \ bit 7 of pressingShiftArrow is clear, so this is a \ new pressing SHIFT-arrow, so we fall through into \ RestartGame with the C flag set to restart the game \ and set bit 7 of pressingShiftArrow .RestartGame LDX startingStack \ Set the stack pointer to the value it had when the TXS \ game started, which clears any stored addresses put on \ the stack by the code we are now exiting from ROR pressingShiftArrow \ Shift the C flag into bit 7 of pressingShiftArrow JMP MainLoop \ Jump to the start of the main game loop to restart the \ game .rest1 LSR pressingShiftArrow \ Clear bit 7 of pressingShiftArrow to indicate that we \ are no longer pressing SHIFT-arrow .rest2 RTS \ Return from the subroutine EQUB &00, &00 \ These bytes appear to be unusedName: CheckRestartKeys [Show more] Type: Subroutine Category: Keyboard Summary: If the restart keys are being pressed, restart the gameContext: See this subroutine in context in the source code References: This subroutine is called as follows: * GetMenuOption calls CheckRestartKeys * WaitForSpaceReturn calls CheckRestartKeys * HeadToTrack calls via RestartGame
Other entry points: RestartGame Restart the game, putting the C flag into bit 7 of pressingShiftArrow
[X]
Subroutine MainLoop (Part 1 of 6) (category: Main loop)
The main game loop: practice laps
[X]
Subroutine ScanKeyboard (category: Keyboard)
Scan the keyboard for a specific key press
[X]
Variable pressingShiftArrow in workspace Zero page
Bit 7 is set if we are pressing SHIFT and right arrow (which restarts the game)
[X]
Label rest1 is local to this routine
[X]
Label rest2 is local to this routine
[X]
Variable startingStack in workspace Zero page
The value of the stack pointer when the game starts, so we can restore it when restarting the game