Skip to navigation

Elite on the BBC Micro

Dashboard: MSBAR (6502SP version)

Name: MSBAR [View in context] Type: Subroutine [Compare versions] Category: Dashboard Summary: Implement the #DOmsbar command (draw a specific indicator in the dashboard's missile bar)
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. 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) Returns: X X is preserved Y Y is set to 0
.MSBAR LDY #2 \ Fetch byte #2 from the parameter block (the number of LDA (OSSC),Y \ the missile indicator) into A ASL A \ Set T = A * 8 ASL A ASL A ASL A STA T LDA #97 \ Set SC = 97 - T SBC T \ = 96 + 1 - (X * 8) STA SC \ So the low byte of SC(1 0) contains the row address \ for the rightmost missile indicator, made up as \ follows: \ \ * 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 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 #&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) 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 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 .MBL2 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) DEY \ Decrement the counter for the next row BNE MBL2 \ Loop back to MBL2 if have more rows to draw RTS \ Return from the subroutine