Skip to navigation

Elite on the BBC Micro and NES

Drawing the screen: CLYNS

[6502 Second Processor version, I/O processor]

Name: CLYNS [Show more] Type: Subroutine Category: Drawing the screen Summary: Implement the #clyns command (clear the bottom of the screen)
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 CLYNS
.CLYNS LDA #20 \ Move the text cursor to row 20, near the bottom of STA YC \ the screen LDA #&6A \ Set SC+1 = &6A, for the high byte of SC(1 0) STA SC+1 JSR TT67 \ Print a newline LDA #0 \ Set SC = 0, so now SC(1 0) = &6A00 STA SC LDX #3 \ We want to clear three text rows, so set a counter in \ X for 3 rows .CLYL LDY #8 \ We want to clear each text row, starting from the \ left, but we don't want to overwrite the border, so we \ start from the second character block, which is byte \ #8 from the edge, so set Y to 8 to act as the byte \ counter within the row .EE2 STA (SC),Y \ Zero the Y-th byte from SC(1 0), which clears it by \ setting it to colour 0, black INY \ Increment the byte counter in Y BNE EE2 \ Loop back to EE2 to blank the next byte along, until \ we have done one page's worth (from byte #8 to #255) INC SC+1 \ We have just finished the first page - which covers \ the left half of the text row - so we increment SC+1 \ so SC(1 0) points to the start of the next page, or \ the start of the right half of the row STA (SC),Y \ Clear the byte at SC(1 0), as that won't be caught by \ the next loop LDY #247 \ The second page covers the right half of the text row, \ and as before we don't want to overwrite the border, \ which we can do by starting from the last-but-one \ character block and working our way left towards the \ centre of the row. The last-but-one character block \ ends at byte 247 (that's 255 - 8, as each character \ is 8 bytes), so we put this in Y to act as a byte \ counter, as before .EE3 STA (SC),Y \ Zero the Y-th byte from SC(1 0), which clears it by \ setting it to colour 0, black DEY \ Decrement the byte counter in Y BNE EE3 \ Loop back to EE2 to blank the next byte to the left, \ until we have done one page's worth (from byte #247 to \ #1) INC SC+1 \ We have now blanked a whole text row, so increment \ SC+1 so that SC(1 0) points to the next row DEX \ Decrement the row counter in X BNE CLYL \ Loop back to blank another row, until we have done the \ number of rows in X \INX \ These instructions are commented out in the original \STX SC \ source JMP PUTBACK \ Jump to PUTBACK to restore the USOSWRCH handler and \ return from the subroutine using a tail call