.ReadJoystick LDA row29_char20_4 \ If the screen byte at row 29, block 20, pixel row 4 is BEQ rjoy1 \ zero (i.e. black) then the joystick is not enabled, so \ jump to rjoy1 to return from the subroutine LDX #1 \ Set aileronPosition to the value from ADC channel 1, JSR ReadADCChannel \ the joystick's x-position, inverted and clipped to the STA aileronPosition \ range -118 to +116 LDX #2 \ Set elevatorPosition to the value from ADC channel 2, JSR ReadADCChannel \ the joystick's y-position, inverted and clipped to the STA elevatorPosition \ range -118 to +116 LDX #0 \ Call OSBYTE with A = 128 and X = 0 to read the status LDA #128 \ of the joystick's fire button into X JSR OSBYTE TXA \ If bit 0 of X is zero, the fire button is not being AND #1 \ pressed, so jump to rjoy1 BEQ rjoy1 LDA #8 \ The fire button is being pressed, so update the key STA keyLoggerLo+5 \ logger at keyLoggerLo+5, which corresponds to the \ flaps and fire keys. We set the value to 8, the value \ from keyTable2Lo for the fire button .rjoy1 RTS \ Return from the subroutine EQUB &36Name: ReadJoystick [Show more] Type: Subroutine Category: Keyboard Summary: Read the joystick axes and fire button and update the aileron, elevator and fire key values accordinglyContext: See this subroutine in context in the source code References: This subroutine is called as follows: * UpdateFlightModel (Part 1 of 4) calls ReadJoystick
[X]
Configuration variable OSBYTE = &FFF4
The address for the OSBYTE routine
[X]
Subroutine ReadADCChannel (category: Keyboard)
Read the joystick position from one of the ADC channels
[X]
Variable aileronPosition in workspace Main variable workspace
Aileron position (roll)
[X]
Variable elevatorPosition in workspace Main variable workspace
Elevator position (pitch)
[X]
Variable keyLoggerLo in workspace Main variable workspace
Key logger (low byte)
[X]
Label rjoy1 is local to this routine
[X]
Configuration variable row29_char20_4 = &7CE4
Joystick indicator block (above middle of rudder)