.uind25 \ If we get here then the indicator number in X is 8 or \ 10 LDA #128 \ Redraw the existing cross on the joystick position JSR DrawJoystickCross \ display using EOR logic, which removes it LDA #%00100010 \ Redraw the joystick position display's x-axis, in case STA row24_char18_7 \ the old cross was overwriting the axis STA row24_char21_7 LDA #%01000100 STA row24_char19_7 LDA #%10011001 \ Redraw the joystick position display's y-axis, in case STA row24_char20_7 \ the old cross was overwriting the axis LDA #%10001000 STA row21_char20_7 STA row22_char20_7 STA row23_char20_7 STA row25_char20_7 STA row26_char20_7 STA row27_char20_7 LDA aileronPosition \ Set A = aileronPosition, the x-position of the \ joystick SEC \ Set the C flag so the following call to ScaleSigned \ divides the joystick x-position by 16 JSR ScaleSigned \ Scale the value in A down by a factor of 16, retaining \ the sign and being sensitive to small values STA xJoyCoord \ Store the scaled value of A in xJoyCoord, so we can \ pass it to DrawJoystickCross below to draw the new \ cross, but also so we can erase this cross when we \ need to update the indicator in the future LDA elevatorPosition \ Set A = elevatorPosition, the y-position of the \ joystick CLC \ Clear the C flag so the following call to ScaleSigned \ divides the joystick y-position by 4 JSR ScaleSigned \ Scale the value in A down by a factor of 4, retaining \ the sign and being sensitive to small values EOR #&FF \ Set A = -A using two's complement CLC \ ADC #1 \ This flips the sign of the y-position, because the \ joystick value will be high when we pull up, but this \ corresponds to moving the stick down, which should be \ shown lower down the indicator STA yJoyCoord \ Store the scaled value of A in yJoyCoord, so we can \ pass it to DrawJoystickCross below to draw the new \ cross, but also so we can erase this cross when we \ need to update the indicator in the future LDA #0 \ Draw a new cross on the joystick position display JSR DrawJoystickCross RTS \ Return from the subroutineName: UpdateIndicator (Part 14 of 15) [Show more] Type: Subroutine Category: Dashboard Summary: Calculations for the joystick position display (indicator 8 or 10)Context: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
This section takes the joystick position from aileronPosition and elevatorPosition and reduces it to -8 to +8 (for the x-position in aileronPosition) and to -32 to +32 (for the y-position in elevatorPosition), before passing it to the DrawJoystickCross to update the cross in the joystick position display. The x-position is reduced more because the joystick position display is taller than it is wide. Note that this indicator has two IDs, 8 and 10, so that it gets updated twice as often by UpdateDashboard.
[X]
Subroutine DrawJoystickCross (category: Drawing lines)
Draw a cross in the joystick position display (indicator 8 or 10)
[X]
Subroutine ScaleSigned (category: Maths)
Scale an indicator value by 4 or 16, retaining the sign and adding sensitivity for smaller values
[X]
Variable aileronPosition in workspace Main variable workspace
Aileron position (roll)
[X]
Variable elevatorPosition in workspace Main variable workspace
Elevator position (pitch)
[X]
Configuration variable row21_char20_7 = &72E7
Top block of joystick position display y-axis
[X]
Configuration variable row22_char20_7 = &7427
Second block of joystick position display y-axis
[X]
Configuration variable row23_char20_7 = &7567
Third block of joystick position display y-axis
[X]
Configuration variable row24_char18_7 = &7697
Left block of joystick position display x-axis
[X]
Configuration variable row24_char19_7 = &769F
Left-middle block of joystick position display x-axis
[X]
Configuration variable row24_char20_7 = &76A7
Fourth block of joystick position display y-axis and right-middle block of joystick position display x-axis
[X]
Configuration variable row24_char21_7 = &76AF
Right block of joystick position display x-axis
[X]
Configuration variable row25_char20_7 = &77E7
Fifth block of joystick position display y-axis
[X]
Configuration variable row26_char20_7 = &7927
Sixth block of joystick position display y-axis
[X]
Configuration variable row27_char20_7 = &7A67
Bottom block of joystick position display y-axis
[X]
Variable xJoyCoord (category: Dashboard)
Temporary storage
[X]
Variable yJoyCoord (category: Dashboard)
Temporary storage