Skip to navigation


Save and load: LOD

[6502 Second Processor version]

Name: LOD [Show more] Type: Subroutine Category: Save and load Summary: Load a commander file
Context: See this subroutine in context in the source code Variations: See code variations for this subroutine in the different versions References: This subroutine is called as follows: * SVE calls LOD * GTDRV calls via LOR

The filename should be stored at INWK, terminated with a carriage return (13).
Other entry points: LOR Set the C flag and return from the subroutine
.LOD \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 \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 &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 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 EQUB &49 \ invalid commander file with bit 7 of byte #0 set EQUS "Illegal " \ (&49 is the error number) EQUS "ELITE II file" BRK \.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