Skip to navigation

Elite on the BBC Micro and NES

Save and load: CATS

[Elite-A, Parasite]

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) 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 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" LDA #&8E \ Send command &8E to the I/O processor: JSR tube_write \ \ write_xyc(x, y, char) \ \ which will draw the text character in char at column x \ and row y, though in this case we're sending a null \ character (char = 0), so this doesn't print anything \ but just moves the text cursor in the I/O processor \ to column XC and row YC LDA XC \ Send the first parameter to the I/O processor: JSR tube_write \ \ * x = XC LDA YC \ Send the second parameter to the I/O processor: JSR tube_write \ \ * y = YC LDA #0 \ Send the third parameter to the I/O processor: JSR tube_write \ \ * char = 0 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 CLC \ Clear the C flag RTS \ Return from the subroutine