Skip to navigation

Elite on the BBC Micro and NES

Utility routines: NEWBRK

[BBC Master version]

Name: NEWBRK [Show more] Type: Subroutine Category: Utility routines Summary: The standard BRKV handler for the game
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: * COLD calls NEWBRK

This routine is used to display error messages, before restarting the game. When called, it makes a beep and prints the system error message in the block pointed to by (&FD &FE), which is where the MOS will put any system errors. It then waits for a key press and restarts the game.
.NEWBRK LDX stackpt \ Set the stack pointer to the value that we stored in TXS \ location stack, so that's back to the value it had \ before we change it in the SVE routine JSR getzp \ Call getzp to restore the top part of zero page from \ the buffer at &3000, as this will have been stored in \ the buffer before performing the disc access that gave \ the error we're processsing STZ CATF \ Set the CATF flag to 0, so the TT26 routine reverts to \ standard formatting LDY #0 \ Set Y to 0, which we use as a loop counter below LDA #7 \ Set A = 7 to generate a beep before we print the error \ message .BRBRLOOP JSR CHPR \ Print the character in A, which contains a line feed \ on the first loop iteration, and then any non-zero \ characters we fetch from the error message INY \ Increment the loop counter LDA (&FD),Y \ Fetch the Y-th byte of the block pointed to by \ (&FD &FE), so that's the Y-th character of the message \ pointed to by the MOS error message pointer BNE BRBRLOOP \ If the fetched character is non-zero, loop back to the \ JSR OSWRCH above to print the it, and keep looping \ until we fetch a zero (which marks the end of the \ message) 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