.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_char20_4 \ Toggle the joystick indicator pixel above the middle EOR #%10001000 \ of the rudder indicator STA row29_char20_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 unusedName: ToggleJoystick [Show more] Type: Subroutine Category: Keyboard Summary: Toggle the joystick settingContext: 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_char20_4 to check the joystick status, so it is not only an on-screen indicator, it's also the joystick status variable.
[X]
Subroutine ScanKeyboard (category: Keyboard)
Scan the keyboard for a specific key
[X]
Variable pressingTab in workspace Main variable workspace
Bit 7 determines whether TAB is being pressed
[X]
Configuration variable row29_char20_4 = &7CE4
Joystick indicator block (above middle of rudder)
[X]
Label tjoy1 is local to this routine
[X]
Label tjoy2 is local to this routine
[X]
Label tjoy3 is local to this routine