Skip to navigation


Save and load: LOD

[Apple II 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 References: This subroutine is called as follows: * SVE calls LOD

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 COPYNAME ; Copy the last saved commander's name from INWK+5 to ; comnam and pad out the rest of comnam with spaces, so ; we can use it as the filename to read in rfile JSR rfile ; Load the commander file into the buffer at comfil BCS diskerror ; If the C flag is set then there was a disk error, so ; jump to diskerror to print the disk error (whose ; number is now in A), make a beep and wait for a key ; press JSR UNMUTILATE ; Decrypt the newly loaded file in the buffer at comfil 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 disk access menu and return ; from the subroutine using a tail call