Skip to navigation

Aviator on the BBC Micro

Dashboard: UpdateIndicator (Part 13 of 15)

Name: UpdateIndicator (Part 13 of 15) [Show more] Type: Subroutine Category: Dashboard Summary: Calculations for the rudder indicator (indicator 9)
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 rudder position from rudderPosition and reduces it to the range -8 to +8, before passing it to DrawIndicatorBar to update the rudder indicator.
.uind24 \ If we get here then the indicator number in X is 9 LDX #1 \ Set X = 1 so the current value of the indicator gets \ stored in yJoyCoord+1 in DrawIndicatorBar LDA #128 \ Set S = 128, to denote that when we fall through into STA S \ DrawIndicatorBar below, joyCoord is the y-coordinate, \ so we draw the indicator's vertical bar from point \ (H + W, joyCoord) LDA #80 \ Set W = 80 to use as the centre y-coordinate for the STA W \ rudder indicator (i.e. the centre bar) LDA rudderPosition \ Set A = rudderPosition SEC \ Set the C flag so the following call to ScaleSigned \ divides the rudder value 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 H \ Store the scaled value in H, which has now been \ reduced from the range -128 to 127 down to -8 to +8, \ to use as the x-coordinate offset from the centre of \ the indicator in DrawIndicatorBar LDY #163 \ Set Y = 163 to use as the y-coordinate of the top of \ the vertical bar LDA #11 \ Set A = 11 to set the height of the vertical bar at 11 \ pixels BNE DrawIndicatorBar \ Jump to DrawIndicatorBar to update indicator 9 by \ drawing a vertical bar of height 11 pixels with \ the top at (80 + H, 163)