Skip to navigation

Elite on the BBC Micro and NES

Save and load: CATS

[Elite-A, Docked]

Name: CATS [Show more] Type: Subroutine Category: Save and load Summary: Ask for a disc drive number and print a catalogue of that drive
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * CAT calls CATS * DELT calls CATS

This routine asks for a disc drive number, and if it is a valid number (0-3) it displays a catalogue of the disc in that drive. It also updates the OS command at CTLI so that when that command is run, it catalogues the correct drive.
Returns: C flag Clear if a valid drive number was entered (0-3), set otherwise
.CATS JSR GTDRV \ Get an ASCII disc drive number from the keyboard in A, \ setting the C flag if an invalid drive number was \ entered BCS DELT-1 \ If the C flag is set, then an invalid drive number was \ entered, so return from the subroutine (as DELT-1 \ contains an RTS) \ --- Mod: Code removed for Elite-A: ------------------> \ STA CTLI+1 \ Store the drive number in the second byte of the \ \ command string at CTLI, so it overwrites the "0" in \ \ ".0" with the drive number to catalogue \ --- And replaced by: --------------------------------> STA CTLI+2 \ Store the drive number in the third byte of the \ command string at CTLI, so it overwrites the "0" in \ ".0" with the drive number to catalogue \ --- End of replacement ------------------------------> STA DTW7 \ Store the drive number in DTW7, so printing extended \ token 4 will show the correct drive number (as token 4 \ contains the {drive number} jump code, which calls \ MT16 to print the character in DTW7) LDA #4 \ Print extended token 4, which clears the screen and JSR DETOK \ prints the boxed-out title "DRIVE {drive number} \ CATALOGUE" \ --- Mod: Code removed for Elite-A: ------------------> \ LDA #1 \ Set the CATF flag to 1, so that the TT26 routine will \ STA CATF \ print out the disc catalogue correctly \ --- And replaced by: --------------------------------> LDA #1 \ Set &0355 to 1. This location in the MOS VDU workspace STA &0355 \ contains the current screen mode, but I'm not entirely \ sure why we need to set it to 1 (the disc catalogue \ seems to work fine if we omit the STA instruction) \ \ The sixth character of the commander name at NAME+5 is \ stored at address &0355, and the overwrite is reversed \ below, after the disc has been catalogued, to avoid \ corrupting the current commander name STA CATF \ Set the CATF flag to 1, so that the TT26 routine will \ print out the disc catalogue correctly \ --- End of replacement ------------------------------> STA XC \ Move the text cursor to column 1 LDX #LO(CTLI) \ Set (Y X) to point to the OS command at CTLI, which LDY #HI(CTLI) \ contains a dot and the drive number, which is the \ DFS command for cataloguing that drive (*. being short \ for *CAT) JSR OSCLI \ Call OSCLI to execute the OS command at (Y X), which \ catalogues the disc DEC CATF \ Decrement the CATF flag back to 0, so the TT26 routine \ reverts to standard formatting \ --- Mod: Code added for Elite-A: --------------------> LDA NA%+5 \ Revert byte #6 of the commander name at NAME+5 to the STA NAME+5 \ correct character from the name at NA%, reversing the \ change we did above \ --- End of added code -------------------------------> CLC \ Clear the C flag RTS \ Return from the subroutine