Skip to navigation


Drawing the screen: CLYNS

[NES version, Bank 7]

Name: CLYNS [Show more] Type: Subroutine Category: Drawing the screen Summary: Clear the bottom two text rows of the visible screen
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * ChangeCmdrName calls CLYNS * dockEd calls CLYNS * FlightLoop4To16 calls CLYNS * HME2 calls CLYNS * JMTB calls CLYNS * SetSelectedSystem calls CLYNS * TT102 calls CLYNS * TT147 calls CLYNS * YESNO calls CLYNS * PrintFlightMessage calls via CLYNS+8

This routine clears some space at the bottom of the screen and moves the text cursor to column 1, row 22.
Other entry points: CLYNS+8 Don't zero DLY and de
.CLYNS LDA #0 ; Set the delay in DLY to 0, to indicate that we are STA DLY ; no longer showing an in-flight message, so any new ; in-flight messages will be shown instantly STA de ; Clear de, the flag that appends " DESTROYED" to the ; end of the next text token, so that it doesn't LDA #%11111111 ; Set DTW2 = %11111111 to denote that we are not STA DTW2 ; currently printing a word LDA #%10000000 ; Set bit 7 of QQ17 to switch standard tokens to STA QQ17 ; Sentence Case LDA #22 ; Move the text cursor to row 22, near the bottom of STA YC ; the screen LDA #1 ; Move the text cursor to column 1 STA XC LDA firstPattern ; Set the next free pattern number in firstFreePattern STA firstFreePattern ; to the value of firstPattern, which contains the ; number of the first pattern for which we send pattern ; data to the PPU in the NMI handler, so it's also the ; pattern we can start drawing into when we next start ; drawing into tiles LDA QQ11 ; If bit 7 of the view type in QQ11 is clear then there BPL clyn2 ; is a dashboard, so jump to clyn2 to return from the ; subroutine LDA #HI(nameBuffer0+23*32) ; Set SC(1 0) to the address of the tile in STA SC+1 ; column 0 on tile row 23 in nametable buffer 0 LDA #LO(nameBuffer0+23*32) STA SC LDA #HI(nameBuffer1+23*32) ; Set SC(1 0) to the address of the tile in STA SC2+1 ; column 0 on tile row 23 in nametable buffer 1 LDA #LO(nameBuffer1+23*32) STA SC2 LDX #2 ; We want to clear two text rows, row 23 and row 24, so ; set a counter in X to count 2 rows .CLYL JSR SetupPPUForIconBar ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 LDY #2 ; We are going to clear tiles from column 2 to 30 on ; each row, so set a tile index in Y to start from ; column 2 LDA #0 ; Set A = 0 to use as the pattern number for the blank ; background tile .EE2 STA (SC),Y ; Set the Y-th tile on the row in nametable buffer 0 to ; the blank tile STA (SC2),Y ; Set the Y-th tile on the row in nametable buffer 1 to ; the blank tile INY ; Increment the tile counter to move on to the next tile CPY #31 ; Loop back to blank the next tile until we have done BNE EE2 ; all the tiles up to column 30 LDA SC ; Add 32 to SC(1 0) to point to the next row, starting ADC #31 ; with the low bytes (the ADC #31 adds 32 because the C STA SC ; flag is set from the comparison above, which resulted ; in equality) STA SC2 ; Add 32 to the low byte of SC2(1 0) as well BCC clyn1 ; If the addition didn't overflow, jump to clyn1 to skip ; the high bytes INC SC+1 ; Increment the high bytes of SC(1 0) and SC2(1 0) INC SC2+1 ; to point to the next page in memory .clyn1 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 .clyn2 RTS ; Return from the subroutine