Skip to navigation

Elite on the BBC Micro

Save and load: LOD (Master 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). Other entry points: LOR Set the C flag and return from the subroutine
.LOD JSR LOAD \ Call LOAD to load the commander file to address &0791 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 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 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 BPL LOL1 \ Loop back until we have copied all NT% bytes .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