Skip to navigation

Elite on the BBC Micro

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. Other entry points:

Code variation 1 of 2A variation in the comments only

This variation is blank in the Master version.

Tap on a version to expand it, and tap it again to show to all variations.

Cassette, Flight, Docked, Electron

6502SP

RE3+2 Auto-recentre the value in X, if keyboard auto-recentre is configured
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 \ jump to RE3 to auto-recentre and return the result 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 \ jump to RE2+2 above to return the result as is, \ 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 version to expand it, and tap it again to show to all variations.

Cassette, Flight, Docked, Electron

6502SP, 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
 BNE RE2+2              \ jump to RE2+2 to restore A and return

 LDX #128               \ If keyboard auto-recentre is enabled, set X to 128
 BMI RE2+2              \ (the middle of our range) and jump to RE2+2 to
                        \ restore A and return

RSS Feed