Skip to navigation

Aviator on the BBC Micro

Keyboard: ToggleJoystick

Name: ToggleJoystick [Show more] Type: Subroutine Category: Keyboard Summary: Toggle the joystick setting
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DrawGunSights calls ToggleJoystick

Note that the game uses row29_block20_4 to check the joystick status, so it is not only an on-screen indicator, it's also the joystick status variable.
.ToggleJoystick LDX #&9F \ Scan the keyboard to see if TAB is being pressed JSR ScanKeyboard BNE tjoy1 \ If TAB is not being pressed, jump to tjoy1 LDA pressingTab \ If pressingTab is non-zero, then we are still pressing BNE tjoy3 \ TAB from a previous visit to this routine, so jump to \ tjoy3 to return from the subroutine \ This is a new press of TAB, so now we want to toggle \ the joystick setting LDA row29_block20_4 \ Toggle the joystick indicator pixel above the middle EOR #%10001000 \ of the rudder indicator STA row29_block20_4 LDA #128 \ Set A = 128 to use as the value for pressingTab below, \ to indicate that TAB is being pressed BNE tjoy2 \ Jump to tjoy2 to skip the following instruction (this \ BNE is effectively a JMP as A is never zero) .tjoy1 LDA #0 \ If we get here then TAB is not being pressed, so we \ set A = 0 to set as the value for pressingTab .tjoy2 STA pressingTab \ Set pressingTab to the value in A, which will be 0 if \ TAB is not being pressed, or 128 if it is being \ pressed .tjoy3 RTS \ Return from the subroutine EQUB &8D \ This byte appears to be unused