Skip to navigation

Elite on the BBC Micro

Save and load: LOD (Disc version)

Name: LOD [View in context] Type: Subroutine [Compare versions] Category: Save and load Summary: Load a commander file
The filename should be stored at INWK, terminated with a carriage return (13).
.LOD \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 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 LDA #&FF \ Call QUS1 with A = &FF, Y = &C to load the commander JSR QUS1 \ file to address &0B00 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 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 .LOL1 LDA &B00,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 BPL LOL1 \ Loop back until we have copied all NT% bytes .LOR SEC \ Set the C flag RTS \ Return from the subroutine .ELT2F BRK \ The error that is printed if we try to load an EQUS "IIllegal " \ invalid commander file with bit 7 of byte #0 set EQUS "ELITE II file" \ (the spelling mistake is in the original source) BRK