Skip to navigation

Elite on the BBC Micro

Version analysis of RES2

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

Code variations between these versions are shown below.

Name: RES2 Type: Subroutine Category: Start and end Summary: Reset a number of flight variables and workspaces
This is called after we launch from a space station, arrive in a new system after hyperspace, launch an escape pod, or die a cold, lonely death in the depths of space. Returns: Y Y is set to &FF
.RES2

Code variation 1 of 13Related to the Electron version

The Electron version has a hard-coded number of stardust particles on-screen, so there is no need to reset it after launch from the station.

This variation is blank in the Electron version.

Cassette, Flight, Docked, 6502SP, Master

LDA #NOST \ Reset NOSTM, the number of stardust particles, to the STA NOSTM \ maximum allowed (18)
 LDX #&FF               \ Reset LSX2 and LSY2, the ball line heaps used by the
 STX LSX2               \ BLINE routine for drawing circles, to &FF, to set the
 STX LSY2               \ heap to empty

 STX MSTG               \ Reset MSTG, the missile target, to &FF (no target)

Code variation 2 of 13Specific to an individual platform

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

Cassette, Docked, 6502SP, Master, Electron

Flight

LDA #128 \ Set the current pitch rate to the mid-point, 128 STA JSTY STA ALP2 \ Reset ALP2 (roll sign) and BET2 (pitch sign) STA BET2 \ to negative, i.e. pitch and roll negative
LDA #128 \ Set the current pitch and roll rates to the mid-point, STA JSTX \ 128 STA JSTY
 ASL A                  \ This sets A to 0

Code variation 3 of 13Specific to an individual platform

This variation is blank in the Cassette, Disc (flight), Disc (docked) and Electron versions.

6502SP, Master

STA BETA \ Reset BETA (pitch angle alpha) to 0 STA BET1 \ Reset BET1 (magnitude of the pitch angle) to 0

Code variation 4 of 13Specific to an individual platform

This variation is blank in the Disc (flight) version.

Cassette, Docked, 6502SP, Master, Electron

STA ALP2+1 \ Reset ALP2+1 (flipped roll sign) and BET2+1 (flipped STA BET2+1 \ pitch sign) to positive, i.e. pitch and roll negative
 STA MCNT               \ Reset MCNT (the main loop counter) to 0

Code variation 5 of 13Specific to an individual platform

This variation is blank in the Cassette, Disc (docked), 6502 Second Processor, Master and Electron versions.

Flight

STA QQ22+1 \ Set the on-screen hyperspace counter to 0

Code variation 6 of 13A variation in the labels only

This variation is blank in the Cassette, Disc (flight), 6502 Second Processor, Master and Electron versions.

Docked

.modify
 LDA #3                 \ Reset DELTA (speed) to 3
 STA DELTA

Code variation 7 of 13Specific to an individual platform

This variation is blank in the Disc (flight) version.

Cassette, Docked, 6502SP, Master, Electron

STA ALPHA \ Reset ALPHA (roll angle alpha) to 3 STA ALP1 \ Reset ALP1 (magnitude of roll angle alpha) to 3

Code variation 8 of 13Specific to an individual platform

This variation is blank in the Cassette, Disc (flight), Disc (docked), 6502 Second Processor and Electron versions.

Master

LDA #0 \ Set XMAX to 0 (though this variable is never used, so STA XMAX \ this has no effect) LDA #191 \ Set YMAX to 191, the number of pixel lines in the STA YMAX \ space view

Code variation 9 of 13Specific to an individual platform

This variation is blank in the Disc (docked) version.

Cassette, Flight, 6502SP, Master, Electron

LDA SSPR \ Fetch the "space station present" flag, and if we are BEQ P%+5 \ not inside the safe zone, skip the next instruction JSR SPBLB \ Light up the space station bulb on the dashboard
 LDA ECMA               \ Fetch the E.C.M. status flag, and if E.C.M. is off,
 BEQ yu                 \ skip the next instruction

 JSR ECMOF              \ Turn off the E.C.M. sound

.yu

 JSR WPSHPS             \ Wipe all ships from the scanner

Code variation 10 of 13A variation in the comments only

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

Cassette, Flight, Docked, Electron

6502SP, Master

JSR ZERO \ Zero-fill pages &9, &A, &B, &C and &D, which clears \ the ship data blocks, the ship line heap, the ship \ slots for the local bubble of universe, and various \ flight and ship status variables
JSR ZERO \ Reset the ship slots for the local bubble of universe, \ and various flight and ship status variables

Code variation 11 of 13Minor and very low-impact

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

Cassette, Electron

Flight, Docked, 6502SP, Master

LDA #LO(WP-1) \ We have reset the ship line heap, so we now point STA SLSP \ SLSP to the byte before the WP workspace to indicate LDA #HI(WP-1) \ that the heap is empty STA SLSP+1
LDA #LO(LS%) \ We have reset the ship line heap, so we now point STA SLSP \ SLSP to LS% (the byte below the ship blueprints at D%) LDA #HI(LS%) \ to indicate that the heap is empty STA SLSP+1

Code variation 12 of 13Specific to an individual platform

This variation is blank in the Master version.

Cassette, Flight, Docked, 6502SP, Electron

JSR DIALS \ Update the dashboard
                        \ Finally, fall through into ZINF to reset the INWK
                        \ ship workspace

Code variation 13 of 13Specific to an individual platform

This variation is blank in the Cassette, Disc (docked), 6502 Second Processor, Master and Electron versions.

Flight

JSR U% \ Call U% to clear the key logger
RSS Feed