Skip to navigation

Elite on the BBC Micro and NES

Version analysis of MSBAR

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

Code variations between these versions are shown below.

Name: MSBAR Type: Subroutine Category: Dashboard

Code variation 1 of 19A variation in the comments only

Tap on a block to expand it, and tap it again to revert.

Summary: Draw a specific indicator in the dashboard's missile bar
Summary: Implement the #DOmsbar command (draw a specific indicator in the dashboard's missile bar)

Code variation 2 of 19A variation in the comments only

Tap on a block to expand it, and tap it again to revert.

Each indicator is a rectangle that's 3 pixels wide and 5 pixels high. If the indicator is set to black, this effectively removes a missile.
Each indicator is a rectangle that's 6 pixels wide and 5 pixels high. If the indicator is set to black, this effectively removes a missile.




Code variation 3 of 19A variation in the comments only

Tap on a block to expand it, and tap it again to revert.

Arguments: X The number of the missile indicator to update (counting from right to left, so indicator NOMSL is the leftmost indicator) Y The colour of the missile indicator: * &00 = black (no missile) * &0E = red (armed and locked) * &E0 = yellow/white (armed) * &EE = green/cyan (disarmed)
Arguments: X The number of the missile indicator to update (counting from right to left, so indicator NOMSL is the leftmost indicator) Y The colour of the missile indicator: * &00 = black (no missile) * #RED2 = red (armed and locked) * #YELLOW2 = yellow/white (armed) * #GREEN2 = green (disarmed)
This routine is run when the parasite sends a #DOmsbar command with parameters in the block at OSSC(1 0). It draws a specific indicator in the dashboard's missile bar. The parameters match those put into the msbpars block in the parasite. Arguments: OSSC(1 0) A parameter block as follows: * Byte #2 = The number of the missile indicator to update (counting from right to left, so indicator NOMSL is the leftmost indicator) * Byte #3 = The colour of the missile indicator: * &00 = black (no missile) * #RED2 = red (armed and locked) * #YELLOW2 = yellow/white (armed) * #GREEN2 = green (disarmed)
Arguments: X The number of the missile indicator to update (counting from right to left, so indicator NOMSL is the leftmost indicator) Y The status of the missile indicator: * &04 = black (no missile) * &11 = black "T" in white square (armed and locked) * &0D = black box in white square (armed) * &09 = white square (disarmed)

Returns: X X is preserved Y Y is set to 0
.MSBAR

Code variation 4 of 19Specific to an individual platform

This variation is blank in the Cassette, Disc (flight), Disc (docked), 6502 Second Processor and Electron versions.

LDA #%00001111 \ Set bits 1 and 2 of the Access Control Register at STA VIA+&34 \ SHEILA &34 to switch screen memory into &3000-&7FFF TXA \ Store the value of X on the stack so we can preserve PHA \ it across the call to this subroutine

Code variation 5 of 19Related to Elite's use of the Tube

This variation is blank in the Cassette, Disc (flight), Disc (docked), Master and Electron versions.

LDY #2 \ Fetch byte #2 from the parameter block (the number of LDA (OSSC),Y \ the missile indicator) into A

Code variation 6 of 19Related to the screen mode

Tap on a block to expand it, and tap it again to revert.

TXA \ Set T = X * 8 ASL A ASL A ASL A STA T LDA #49 \ Set SC = 49 - T SBC T \ = 48 + 1 - (X * 8) STA SC
ASL A \ Set T = A * 16 ASL A ASL A ASL A STA T LDA #97 \ Set SC = 97 - T SBC T \ = 96 + 1 - (X * 16) STA SC
TXA \ Store X on the stack, so we can preserve it across PHA \ the call to the subroutine ASL A \ Set T = X * 8 ASL A ASL A STA T LDA #209 \ Set SC = &80 + 32 + 49 - T SBC T \ = &80 + 32 + 48 + 1 - (X * 8) STA SC \ \ The &80 part comes from the fact that the character \ row containing the missile starts at address &7D80, \ and the low byte of this is &80 \ \ The 32 part comes from the 32-byte blank border to \ the left of the screen \ \ And the 48 part is from character block 7, which is \ the character block containing the missile indicators
                        \ So the low byte of SC(1 0) contains the row address
                        \ for the rightmost missile indicator, made up as
                        \ follows:
                        \

Code variation 7 of 19A variation in the comments only

This variation is blank in the Cassette, Disc (flight), Disc (docked), 6502 Second Processor and Master versions.

\ * &80 + 32 as described above \

Code variation 8 of 19A variation in the comments only

Tap on a block to expand it, and tap it again to revert.

\ * 48 (character block 7, as byte #7 * 8 = 48), the
\ * 96 (character block 14, as byte #14 * 8 = 96), the
                        \     character block of the rightmost missile
                        \
                        \   * 1 (so we start drawing on the second row of the
                        \     character block)
                        \
                        \   * Move left one character (8 bytes) for each count
                        \     of X, so when X = 0 we are drawing the rightmost
                        \     missile, for X = 1 we hop to the left by one
                        \     character, and so on

Code variation 9 of 19Related to the screen mode

Tap on a block to expand it, and tap it again to revert.

LDA #&7E \ Set the high byte of SC(1 0) to &7E, the character row STA SCH \ that contains the missile indicators (i.e. the bottom \ row of the screen)
LDA #&7C \ Set the high byte of SC(1 0) to &7C, the character row STA SCH \ that contains the missile indicators (i.e. the bottom \ row of the screen)
LDA #&7D \ Set the high byte of SC(1 0) to &7D, the high byte of STA SCH \ &7D80, which is the start of the character row that \ contains the missile indicators (i.e. the bottom row \ of the screen)

Code variation 10 of 19Related to the Electron version

The monochrome dashboard can't use colour to indicate the status of the missiles, so instead the Electron version uses four different bitmaps - black (no missile), white box (disarmed), black box in white square (armed), and black "T" in white square (armed and locked).

See below for more variations related to this code.

This variation is blank in the 6502 Second Processor and Master versions.

Tap on a block to expand it, and tap it again to revert.

TYA \ Set A to the correct colour, which is a 3-pixel wide \ mode 5 character row in the correct colour (for \ example, a green block has Y = &EE, or %11101110, so \ the missile blocks are 3 pixels wide, with the \ fourth pixel on the character row being empty)
TYA \ Set X to the indicator status that was passed to the TAX \ subroutine, so we can use it below as an index into \ the MDIALS table when fetching the bitmap to set the \ missile indicator to

Code variation 11 of 19Related to the screen mode

This variation is blank in the Cassette, Disc (flight), Disc (docked) and Electron versions.

Tap on a block to expand it, and tap it again to revert.

TYA \ Set A to the correct colour, which is a 2-pixel wide \ mode 2 character row byte in the specified colour
LDY #3 \ Fetch byte #2 from the parameter block (the indicator LDA (OSSC),Y \ colour) into A. This is one of #GREEN2, #YELLOW2 or \ #RED2, or 0 for black, so this is a 2-pixel wide mode \ 2 character row byte in the specified colour

Code variation 12 of 19Related to the screen mode

This variation is blank in the Cassette, Disc (flight), Disc (docked) and Electron versions.

LDY #5 \ We now want to draw this line five times to do the \ left two pixels of the indicator, so set a counter in \ Y .MBL1 STA (SC),Y \ Draw the 3-pixel row, and as we do not use EOR logic, \ this will overwrite anything that is already there \ (so drawing a black missile will delete what's there) DEY \ Decrement the counter for the next row BNE MBL1 \ Loop back to MBL1 if have more rows to draw PHA \ Store the value of A on the stack so we can retrieve \ it after the following addition LDA SC \ Set SC = SC + 8 CLC \ ADC #8 \ so SC(1 0) now points to the next character block on STA SC \ the row (for the right half of the indicator) PLA \ Retrieve A from the stack AND #%10101010 \ Mask the character row to plot just the first pixel \ in the next character block, as we already did a \ two-pixel wide band in the previous character block, \ so we need to plot just one more pixel, width-wise
 LDY #5                 \ We now want to draw this line five times, so set a
                        \ counter in Y

Code variation 13 of 19A variation in the labels only

Tap on a block to expand it, and tap it again to revert.

.MBL1
.MBL2

Code variation 14 of 19Related to the Electron version

See variation 10 above for details.

This variation is blank in the Cassette, Disc (flight), Disc (docked), 6502 Second Processor and Master versions.

LDA MDIALS,X \ Fetch the X-th bitmap from the MDIALS table

Code variation 15 of 19A variation in the comments only

Tap on a block to expand it, and tap it again to revert.

STA (SC),Y \ Draw the 3-pixel row, and as we do not use EOR logic,
STA (SC),Y \ Draw the 1-pixel row, and as we do not use EOR logic,
                        \ this will overwrite anything that is already there
                        \ (so drawing a black missile will delete what's there)

Code variation 16 of 19Related to the Electron version

See variation 10 above for details.

This variation is blank in the Cassette, Disc (flight), Disc (docked), 6502 Second Processor and Master versions.

DEX \ Decrement the bitmap counter for the next row
 DEY                    \ Decrement the counter for the next row

Code variation 17 of 19A variation in the labels only

Tap on a block to expand it, and tap it again to revert.

BNE MBL1 \ Loop back to MBL1 if have more rows to draw
BNE MBL2 \ Loop back to MBL2 if have more rows to draw

Code variation 18 of 19Specific to an individual platform

This variation is blank in the Cassette, Disc (flight), Disc (docked) and 6502 Second Processor versions.

Tap on a block to expand it, and tap it again to revert.

PLX \ Restore X from the stack, so that it's preserved IF _SNG47 LDA #%00001001 \ Clear bits 1 and 2 of the Access Control Register at STA VIA+&34 \ SHEILA &34 to switch main memory back into &3000-&7FFF RTS \ Return from the subroutine ELIF _COMPACT JMP away \ Jump to away to switch main memory back into \ &3000-&7FFF and return from the subroutine ENDIF
PLA \ Restore X from the stack, so that it's preserved TAX

Code variation 19 of 19Specific to an individual platform

This variation is blank in the Master version.

RTS \ Return from the subroutine