Skip to navigation

Elite on the BBC Micro and NES

Save and load: LOD

[BBC Master 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 JSR rfile \ Call rfile to load the commander file to the TAP% \ staging area LDA TAP% \ 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 to the \ TAP% staging area, 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 .copyme LDA TAP%,Y \ Copy the Y-th byte of TAP% to the Y-th byte of NA%+8 STA NA%+8,Y DEY \ Decrement the loop counter BPL copyme \ 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 .backtonormal RTS \ Return from the subroutine .CLDELAY RTS \ This instruction has no effect as we already returned \ from the subroutine