Skip to navigation

Elite on the BBC Micro

Save and load: QUS1 [Elite-A, Docked]

Name: QUS1 [Show more] Type: Subroutine Category: Save and load Summary: Save or load the commander file Deep dive: Commander save files
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * LOD calls QUS1 * SVE calls QUS1

The filename should be stored at INWK, terminated with a carriage return (13). The routine should be called with Y set to &C. Arguments: A File operation to be performed. Can be one of the following: * 0 (save file) * &FF (load file) Y Points to the page number containing the OSFILE block, which must be &C because that's where the pointer to the filename in INWK is stored below (by the STX &0C00 instruction)
.QUS1 PHA \ Store A on the stack so we can restore it after the \ call to GTDRV JSR GTDRV \ Get an ASCII disc drive drive number from the keyboard \ in A, setting the C flag if an invalid drive number \ was entered STA INWK+1 \ Store the ASCII drive number in INWK+1, which is the \ drive character of the filename string ":0.E." PLA \ Restore A from the stack BCS QUR \ If the C flag is set, then an invalid drive number was \ entered, so jump to QUR to return from the subroutine \ --- Mod: Code added for Elite-A: --------------------> STA save_lock \ Set save_lock to 0 (when we save a file) or &FF (when \ we load a file) to indicate: \ \ * 0 = last file operation was a save \ \ * &FF = last file operation was a load \ --- End of added code -------------------------------> LDX #INWK \ Store a pointer to INWK at the start of the block at STX &0C00 \ &0C00, storing #INWK in the low byte because INWK is \ in zero page LDX #0 \ Set (Y X) = &0C00 LDY #&C JSR OSFILE \ Call OSFILE to do the file operation specified in \ &0C00 (i.e. save or load a file depending on the value \ of A) CLC \ Clear the C flag .QUR RTS \ Return from the subroutine