Skip to navigation

Elite on the BBC Micro and NES

Dashboard: DOBULB

[6502 Second Processor version, I/O processor]

Name: DOBULB [Show more] Type: Subroutine Category: Dashboard Summary: Implement the #DOBULB 0 command (draw the space station indicator bulb)
Context: See this subroutine in context in the source code Variations: See code variations for this subroutine in the different versions References: This subroutine is called as follows: * JMPTAB calls DOBULB

This routine is run when the parasite sends a #DOBULB 0 command. It draws (or erases) the space station indicator bulb ("S") on the dashboard.
.DOBULB TAX \ If the parameter to the #DOBULB command is non-zero, BNE ECBLB \ i.e. this is a #DOBULB 255 command, jump to ECBLB to \ draw the E.C.M. bulb instead LDA #16*8 \ The space station bulb is in character block number 48 STA SC \ (counting from the left edge of the screen), with the \ first half of the row in one page, and the second half \ in another. We want to set the screen address to point \ to the second part of the row, as the bulb is in that \ half, so that's character block number 16 within that \ second half (as the first half takes up 32 character \ blocks, so given that each character block takes up 8 \ bytes, this sets the low byte of the screen address \ of the character block we want to draw to LDA #&7B \ Set the high byte of SC(1 0) to &7B, as the bulbs are STA SC+1 \ both in the character row from &7A00 to &7BFF, and the \ space station bulb is in the right half, which is from \ &7B00 to &7BFF LDY #15 \ Now to poke the bulb bitmap into screen memory, and \ there are two character blocks' worth, each with eight \ lines of one byte, so set a counter in Y for 16 bytes .BULL LDA SPBT,Y \ Fetch the Y-th byte of the bulb bitmap EOR (SC),Y \ EOR the byte with the current contents of screen \ memory, so drawing the bulb when it is already \ on-screen will erase it STA (SC),Y \ Store the Y-th byte of the bulb bitmap in screen \ memory DEY \ Decrement the loop counter BPL BULL \ Loop back to poke the next byte until we have done \ all 16 bytes across two character blocks JMP PUTBACK \ Jump to PUTBACK to restore the USOSWRCH handler and \ return from the subroutine using a tail call