Skip to navigation

Elite on the BBC Micro

Version analysis of LOD

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

Code variations between these versions are shown below.

Name: LOD Type: Subroutine Category: Save and load Summary: Load a commander file
The filename should be stored at INWK, terminated with a carriage return (13).

Code variation 1 of 11A variation in the comments only

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

6502SP, Master

Other entry points: LOR Set the C flag and return from the subroutine
.LOD

Code variation 2 of 11A variation in the comments only

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

6502SP

\LDX #LO(MINI) \ These instructions are commented out in the original \LDY #HI(MINI) \ source, but they would load a commander file called \JSR OSCLI \ "E.MINING" and continue below, so presumably this is \JMP LOL1-2 \ code for loading a test commander file

Code variation 3 of 11Specific to an individual platform

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, Electron

Docked

6502SP

LDX #2 \ Enable the ESCAPE key and clear memory if the BREAK JSR FX200 \ key is pressed (*FX 200,2) 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 ZEBC \ Call ZEBC to zero-fill pages &B and &C
\LDX #2 \ These instructions are commented out in the original \JSR FX200 \ source, but they would enable the ESCAPE key and clear \ memory if the BREAK key is pressed (*FX 200,2) JSR ZEBC \ Call ZEBC to zero-fill pages &B and &C

Code variation 4 of 11Specific to an individual platform

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, Docked, 6502SP

Electron

LDY #&B \ Set up an OSFILE block at &0C00, containing: STY &0C03 \ INC &0C0B \ Load address = &00000B00 in &0C02 to &0C05 \ \ Length of file = &00000100 in &0C0A to &0C0D
LDY #&9 \ Set up an OSFILE block at &0A00, containing: STY &0A03 \ INC &0A0B \ Load address = &00000900 in &0A02 to &0A05 \ \ Length of file = &00000100 in &0A0A to &0A0D

Code variation 5 of 11A variation in the comments only

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

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

Cassette

Electron

INY \ Increment Y to &C, which we use next
INY \ Increment Y to &A, which we use next

Code variation 6 of 11Specific to an individual platform

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

Cassette, Docked, 6502SP, Electron

Master

LDA #&FF \ Call QUS1 with A = &FF, Y = &C to load the commander JSR QUS1 \ file to address &0B00
JSR LOAD \ Call LOAD to load the commander file to address &0791

Code variation 7 of 11Specific 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

LDA &0B00 \ If the first byte of the loaded file has bit 7 set, BMI SPS1+1 \ jump to SPS+1, which is the second byte of an LDA #0 \ instruction, i.e. a BRK instruction, which will force \ an interrupt to call the address in BRKV, which is set \ to BR1... so this instruction restarts the game from \ the title screen. Valid commander files for the \ cassette version of Elite only have 0 for the first \ byte, as there are no missions in this version, so \ having bit 7 set is invalid anyway
BCS LOR \ If the C flag is set then an invalid drive number was \ entered during the call to QUS1 and the file wasn't \ loaded, so jump to LOR to return from the subroutine LDA &0B00 \ If the first byte of the loaded file has bit 7 set, BMI ELT2F \ jump to ELT2F, as this is an invalid commander file \ \ ELT2F contains a BRK instruction, which will force an \ interrupt to call the address in BRKV, which will \ print out the system error at ELT2F
LDA &0791 \ If the first byte of the loaded file has bit 7 set, BMI ELT2F \ jump to ELT2F, as this is an invalid commander file \ \ ELT2F contains a BRK instruction, which will force an \ interrupt to call the address in BRKV, which will \ print out the system error at ELT2F
LDA &0900 \ If the first byte of the loaded file has bit 7 set, BMI SPS1+1 \ jump to SPS+1, which is the second byte of an LDA #0 \ instruction, i.e. a BRK instruction, which will force \ an interrupt to call the address in BRKV, which is set \ to BR1... so this instruction restarts the game from \ the title screen. Valid commander files for the \ cassette version of Elite only have 0 for the first \ byte, as there are no missions in this version, so \ having bit 7 set is invalid anyway

Code variation 8 of 11Specific to an individual platform

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

Cassette, Docked, 6502SP, Electron

Master

LDX #NT% \ We have successfully loaded the commander file at \ &0B00, so now we want to copy it to the last saved \ commander data block at NA%+8, so we set up a counter \ in X to copy NT% bytes
LDY #NT% \ We have successfully loaded the commander file at \ &0791, so now we want to copy it to the last saved \ commander data block at NA%+8, so we set up a counter \ in Y to copy NT% bytes
.LOL1

Code variation 9 of 11Specific 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

LDA &0B00,X \ Copy the X-th byte of &0B00 to the X-th byte of NA%+8 STA NA%+8,X DEX \ Decrement the loop counter
LDA &0791,Y \ Copy the Y-th byte of &0791 to the Y-th byte of NA%+8 STA NA%+8,Y DEY \ Decrement the loop counter
LDA &0900,X \ Copy the X-th byte of &0900 to the X-th byte of NA%+8 STA NA%+8,X DEX \ Decrement the loop counter
 BPL LOL1               \ Loop back until we have copied all NT% bytes

Code variation 10 of 11Specific to an individual platform

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

Cassette, Electron

Docked, 6502SP

Master

LDX #3 \ Fall through into FX200 to disable the ESCAPE key and \ clear memory if the BREAK key is pressed (*FX 200,3) \ and return from the subroutine there
.LOR SEC \ Set the C flag RTS \ Return from the subroutine .ELT2F BRK \ The error that is printed if we try to load an EQUB &49 \ invalid commander file with bit 7 of byte #0 set EQUS "Illegal " \ (&49 is the error number) EQUS "ELITE II file" BRK
.LOR SEC \ Set the C flag RTS \ Return from the subroutine .ELT2F LDA #9 \ Print extended token 9 ("{cr}{all caps}ILLEGAL ELITE JSR DETOK \ II FILE{sentence case}") JSR t \ Scan the keyboard until a key is pressed, returning \ the ASCII code in A and X JMP SVE \ Jump to SVE to display the disc access menu and return \ from the subroutine using a tail call RTS \ Return from the subroutine RTS \ This instruction has no effect as we already returned \ from the subroutine

Code variation 11 of 11A variation in the comments only

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

6502SP

\.MINI \ These instructions are commented out in the original \EQUS "L.E.MINING B00" \ source, and form part of the commented section above \EQUB 13