Skip to navigation

Elite on the BBC Micro

Dashboard: MSBAR (Electron version)

Name: MSBAR [View in context] Type: Subroutine [Compare versions] Category: Dashboard Summary: Draw a specific indicator in the dashboard's missile bar
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. 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 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: \ \ * &80 + 32 as described above \ \ * 48 (character block 7, as byte #7 * 8 = 48), the \ character block of the rightmost missile \ \ * 1 (so we start drawing on the second row of the \ character block) \ \ * Move right 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 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) 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 LDY #5 \ We now want to draw this line five times, so set a \ counter in Y .MBL1 LDA MDIALS,X \ Fetch the X-th bitmap from the MDIALS table 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) DEX \ Decrement the bitmap counter for the next row DEY \ Decrement the counter for the next row BNE MBL1 \ Loop back to MBL1 if have more rows to draw PLA \ Restore X from the stack, so that it's preserved TAX RTS \ Return from the subroutine