Elite on the BBC Micro and NES

# Version analysis of REDU2

This code appears in the following versions (click to see it in the source code):

Code variations between these versions are shown below.

```       Name: REDU2
Type: Subroutine
Category: Dashboard
Summary: Reduce the value of the pitch or roll dashboard indicator

Reduce X by A, where X is either the current rate of pitch or the current
rate of roll.

The rate of pitch or roll ranges from 1 to 255 with 128 as the centre point.
This is the amount by which the pitch or roll is currently changing, so 1
means it is decreasing at the maximum rate, 128 means it is not changing,
and 255 means it is increasing at the maximum rate. These values correspond
to the line on the DC or RL indicators on the dashboard, with 1 meaning full
left, 128 meaning the middle, and 255 meaning full right.

If reducing X would bring it below 1, then X is set to 1.

If keyboard auto-recentre is configured and the result is greater than 128, we
reduce X down to the mid-point, 128. This is the equivalent of having a roll
or pitch in the right half of the indicator, when decreasing the roll or pitch
should jump us straight to the mid-point.

```

Code variation 1 of 2A variation in the comments only

Tap on a block to expand it, and tap it again to revert.

```Cassette, Flight, Docked, Electron6502SP, Master Other entry points:

RE3+2                Auto-recentre the value in X, if keyboard auto-recentre
is configured
Other entry points:

djd1                 Auto-recentre the value in X, if keyboard auto-recentre
is configured
```
```
.REDU2

STA T                  \ Store argument A in T so we can restore it later

TXA                    \ Copy argument X into A

SEC                    \ Set the C flag so we can do subtraction without the
\ C flag affecting the result

SBC T                  \ Set X = A = argument X - argument A
TAX

BCS RE3                \ If the C flag is set, then we didn't underflow, so

LDX #1                 \ We have an underflow, so set X to the minimum possible
\ value, 1

.RE3

BPL RE2+2              \ If X has bit 7 clear (i.e. the result < 128), then
\ because the result is on the left side of the centre
\ point of 128, so we don't need to auto-centre

```

Code variation 2 of 2A variation in the labels only

Tap on a block to expand it, and tap it again to revert.

```Cassette, Flight, Docked, Electron6502SP, Master                        \ Jumps to RE3+2 end up here
.djd1
```
```                        \ If we get here, then we need to apply auto-recentre,
\ if it is configured

LDA DJD                \ If keyboard auto-recentre is disabled, then