This code appears in the following versions (click to see it in the source code):
Code variations between these versions are shown below.
Name: SVE Type: Subroutine Category: Save and load
This variation is blank in the Cassette, Disc (docked), Master and Electron versions.
Returns: C flag Set if we loaded a new file, clear otherwise
.SVE
This variation is blank in the Cassette and Electron versions.
Tap on a block to expand it, and tap it again to revert.
This variation is blank in the Cassette, Master and Electron versions.
Tap on a block to expand it, and tap it again to revert.
The enhanced versions show a disc access menu when the "@" key is pressed, which lets you load and save commanders, catalogue discs and delete files.
See below for more variations related to this code.
This variation is blank in the Cassette and Electron versions.
Tap on a block to expand it, and tap it again to revert.
Code variation 6 of 20
See variation 5 above for details.
Tap on a block to expand it, and tap it again to revert.
JSR TRNME \ Transfer the commander filename from INWK to NA%
This variation is blank in the Disc (docked), 6502 Second Processor and Master versions.
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
LSR SVC \ Halve the save count value in SVC
In the disc and 6502SP versions, the competition number is labelled as such when saving. In the cassette version, it is just displayed as a standalone number, without any clues as to what it is, while the Master doesn't show the number at all.
This variation is blank in the Cassette and Electron versions.
Tap on a block to expand it, and tap it again to revert.
LDX #NT% \ We now want to copy the current commander data block \ from location TP to the last saved commander block at \ NA%+8, so set a counter in X to copy the NT% bytes in \ the commander data block
\ \ We also want to copy the data block to another \ location &0B00, which is normally used for the ship \ lines heap
.SVL1
DEX \ Decrement the loop counter BPL SVL1 \ Loop back until we have copied all the bytes in the \ commander data block
This variation is blank in the Cassette, Disc (docked), 6502 Second Processor and Electron versions.
\JSR CHECK2 \ These instructions are commented out in the original \STA CHK3 \ source
JSR CHECK \ Call CHECK to calculate the checksum for the last \ saved commander and return it in A STA CHK \ Store the checksum in CHK, which is at the end of the \ last saved commander block PHA \ Store the checksum on the stack ORA #%10000000 \ Set K = checksum with bit 7 set STA K EOR COK \ Set K+2 = K EOR COK (the competition flags) STA K+2 EOR CASH+2 \ Set K+1 = K+2 EOR CASH+2 (the third cash byte) STA K+1 EOR #&5A \ Set K+3 = K+1 EOR &5A EOR TALLY+1 (the high byte of EOR TALLY+1 \ the kill tally) STA K+3
This is a bug fix in the enhanced versions to stop the competition code being printed with a decimal point, which can sometimes happen in the cassette and Electron versions.
This variation is blank in the Cassette and Electron versions.
CLC \ Clear the C flag so the call to BPRNT does not include \ a decimal point
The Master version doesn't show the competition number when saving, as the competition closed some time before the Master came on the scene.
This variation is blank in the Master version.
JSR BPRNT \ Print the competition number stored in K to K+3. The \ value of U might affect how this is printed, and as \ it's a temporary variable in zero page that isn't \ reset by ZERO, it might have any value, but as the \ competition code is a 10-digit number, this just means \ it may or may not have an extra space of padding
PLA \ Restore the checksum from the stack
This variation is blank in the Master version.
Tap on a block to expand it, and tap it again to revert.
EOR #&A9 \ Store the checksum EOR &A9 in CHK2, the penultimate STA CHK2 \ byte of the last saved commander block
This variation is blank in the Master version.
Tap on a block to expand it, and tap it again to revert.
This variation is blank in the Disc (docked), 6502 Second Processor, Master and Electron versions.
LDA #%10000001 \ Clear 6522 System VIA interrupt enable register IER STA VIA+&4E \ (SHEILA &4E) bit 1 (i.e. enable the CA2 interrupt, \ which comes from the keyboard) INC SVN \ Increment SVN to indicate we are about to start saving
This variation is blank in the Disc (docked) and Master versions.
Tap on a block to expand it, and tap it again to revert.