Skip to navigation

Elite on the BBC Micro

Version analysis of BRBR

This code appears in the following versions (click to see it in the source code):

Code variations between these versions are shown below.

Name: BRBR Type: Subroutine Category: Utility routines Summary: The standard BRKV handler for the game
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.

Code variation 1 of 6A variation in the comments only

This variation is blank in the Disc (docked) and Master versions.

6502SP

BRKV is set to this routine in the decryption routine at DEEOR just before the game is run for the first time, and at the end of the SVE routine after the disc access menu has been processed. In other words, this is the standard BRKV handler for the game, and it's swapped out to MEBRK for disc access operations only. When it is the BRKV handler, the routine can be triggered using a BRK instruction. The main differences between this routine and the MEBRK handler that is used during disc access operations are that this routine restarts the game rather than returning to the disc access menu, and this handler decrements the brkd counter.
.BRBR

Code variation 2 of 6Specific to an individual platform

This variation is blank in the Master version.

Docked, 6502SP

DEC brkd \ Decrement the brkd counter

Code variation 3 of 6Specific to an individual platform

This variation is blank in the Disc (docked) version.

Tap on a version to expand it, and tap it again to show to all variations.

Master

6502SP

LDX stack \ 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 SWAPZP \ Call SWAPZP to restore the top part of zero page 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
LDX #&FF \ Set the stack pointer to &01FF, which is the standard TXS \ location for the 6502 stack, so this instruction \ effectively resets the stack JSR backtonormal \ Disable the keyboard and set the SVN flag to 0 TAY \ The call to backtonormal sets A to 0, so this sets 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

Code variation 4 of 6A variation in the labels only

This variation is blank in the Disc (docked) version.

Tap on a version to expand it, and tap it again to show to all variations.

Master

6502SP

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
JSR OSWRCH \ 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

Code variation 5 of 6Specific to an individual platform

This variation is blank in the Disc (docked) version.

6502SP, Master

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)

Code variation 6 of 6Minor and very low-impact

Tap on a version to expand it, and tap it again to show to all variations.

Docked

Master

6502SP

BNE BR1 \ If the brkd counter is non-zero, jump to BR1 to \ restart the game
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
JMP BR1 \ Jump to BR1 to restart the game
RSS Feed