Skip to navigation

Elite on the BBC Micro

Dashboard: MSBAR [Elite-A, Docked]

Name: MSBAR [Show more] Type: Subroutine Category: Dashboard Summary: Draw a specific indicator in the dashboard's missile bar
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * msblob calls MSBAR

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. Note that there are only four missile indicators on the dashboard, but in Elite-A our ship can have up to 7 missiles, in which case the leftmost missile indicator is used for the next missile to use, and the extra missiles are implied rather than displayed. Arguments: X The number of the missile indicator to update (counting from right to left and starting at 0 rather than 1, so indicator NOMSL - 1 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) Returns: X X is preserved Y Y is set to 0
.MSBAR TXA \ Set T = X * 8 ASL A ASL A ASL A STA T \ --- Mod: Original Acornsoft code removed: -----------> \ LDA #49 \ Set SC = 49 - T \ SBC T \ = 48 + 1 - (X * 8) \ STA SC \ --- And replaced by: --------------------------------> LDA #41 \ Set SC = 41 - T SBC T \ = 40 + 1 - (X * 8) STA SC \ = 48 + 1 - ((X + 1) * 8) \ \ This is the same calculation as in the disc version's \ MSBAR routine, but because the missile number in the \ Elite-A version is in the range 0-3 rather than 1-3, \ we subtract from 41 instead of 49 to get the screen \ address \ --- End of replacement ------------------------------> \ So the low byte of SC(1 0) contains the row address \ for the rightmost missile indicator, made up as \ follows: \ \ * 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 #&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) 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) LDY #5 \ We now want to draw this line five times, 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 RTS \ Return from the subroutine