# Dashboard: UpdateIndicator (Part 3 of 15)

```       Name: UpdateIndicator (Part 3 of 15)                          [Show more]
Type: Subroutine
Category: Dashboard
Summary: Calculations for the airspeed indicator (indicator 1)
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 forward airspeed from (zVelocityPHi zVelocityPLo) and
reduces it to match the scale of the indicator, which is represented by a
value of 9 (for 50 mph) to 74 (for 400 mph). The airspeed value can be outside
these limits, but these examples show the scale factor.

It then passes this value to the DrawIndicatorHand to update the on-screen
airspeed indicator.

.uind2

\ If we get here then the indicator number in X is 1

LDA zVelocityPHi       \ If the high byte of the forward airspeed in zVelocityP
BPL uind3              \ is positive, jump down to uind3 to skip the following

LDA #0                 \ The airspeed is negative, so set A to 0 and jump to
JMP DrawIndicatorHand  \ DrawIndicatorHand to zero the indicator on-screen,
\ returning from the subroutine using a tail call

.uind3

LDA zVelocityPLo       \ Set A = (zVelocityPHi zVelocityPLo) * 2 / 256
ASL A
LDA zVelocityPHi
ROL A

\ So by now, A matches the range of the airspeed
\ indicator - here's why:
\
\ The indicatorBase for this indicator is 48 and the
\ indicatorMin/Max range shown on the dial is 57 to 122,
\ which represents 50 to 400 mph (according to the game
\ manual)
\
\ So after this scaling, a result in A of 9 represents
\ 50 mph (as 48 + 9 = 57), and a result in A of 74
\ represents 400 mph (as 48 + 74 = 122), for example
\
\ These values correspond to the following 16-bit values
\ of (zVelocityPHi zVelocityPLo):
\
\   * If A = 9, then airspeed = (00000100 10100000),
\     which is 1184, or 50 mph
\
\   * If A = 74, then airspeed = (00100101 00000000),
\     which is 9472, or 400 mph
\
\ The plane can go faster or slower than in these
\ examples, but the dial only shows speeds between 50mph
\ and 400 mph, so higher or lower speeds will be clipped

JMP DrawIndicatorHand  \ Apply min and max limits to the value in A and update
\ the indicator on-screen, returning from the subroutine
\ using a tail call
```