Skip to navigation

Aviator on the BBC Micro

Keyboard: ReadJoystick

Name: ReadJoystick [Show more] Type: Subroutine Category: Keyboard Summary: Read the joystick axes and fire button and update the aileron, elevator and fire key values accordingly
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * UpdateFlightModel (Part 1 of 4) calls ReadJoystick
.ReadJoystick LDA row29_block20_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 &36