Skip to navigation

Revs on the BBC Micro

Keyboard: CheckRestartKeys

Name: CheckRestartKeys [Show more] Type: Subroutine Category: Keyboard Summary: If the restart keys are being pressed, restart the game
Context: 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
.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 unused