.SendScreenToPPU LDA updatePaletteInNMI ; If updatePaletteInNMI is non-zero, then jump up to BNE SendPalettesToPPU ; SendPalettesToPPU to send the palette data in XX3 to ; the PPU, before continuing with the next instruction JSR SendBuffersToPPU ; Send the contents of the nametable and pattern buffers ; to the PPU to update the screen JSR SetPPURegisters ; Set PPU_CTRL, PPU_ADDR and PPU_SCROLL for the current ; hidden bitplane LDA cycleCount ; Add 100 ($0064) to cycleCount CLC ADC #$64 STA cycleCount LDA cycleCount+1 ADC #$00 STA cycleCount+1 BMI upsc1 ; If the result is negative, jump to upsc1 to stop ; sending PPU data in this VBlank, as we have run out of ; cycles (we will pick up where we left off in the next ; VBlank) JSR ClearBuffers ; The result is positive, so we have enough cycles to ; keep sending PPU data in this VBlank, so call ; ClearBuffers to reset the buffers for both bitplanes .upsc1 LDA #%00011110 ; Configure the PPU by setting PPU_MASK as follows: STA PPU_MASK ; ; * Bit 0 clear = normal colour (i.e. not monochrome) ; * Bit 1 set = show leftmost 8 pixels of background ; * Bit 2 set = show sprites in leftmost 8 pixels ; * Bit 3 set = show background ; * Bit 4 set = show sprites ; * Bit 5 clear = do not intensify greens ; * Bit 6 clear = do not intensify blues ; * Bit 7 clear = do not intensify reds RTS ; Return from the subroutineName: SendScreenToPPU [Show more] Type: Subroutine Category: PPU Summary: Update the screen with the contents of the buffers Deep dive: Drawing vector graphics using NES tilesContext: See this subroutine in context in the source code References: This subroutine is called as follows: * NMI calls SendScreenToPPU * SendPalettesToPPU calls via SendScreenToPPU+4
Other entry points: SendScreenToPPU+4 Re-entry point following the call to SendPalettesToPPU at the start of the routine
[X]
Subroutine ClearBuffers (category: Drawing the screen)
If there are enough free cycles, clear down the nametable and pattern buffers for both bitplanes
[X]
Configuration variable PPU_MASK = $2001
The PPU mask register, which controls how sprites and the tile background are displayed
[X]
Subroutine SendBuffersToPPU (Part 1 of 3) (category: PPU)
Send the icon bar nametable and palette data to the PPU, if it has changed, before moving on to tile data in part 2
[X]
Subroutine SendPalettesToPPU (category: PPU)
Send the palette data from XX3 to the PPU
[X]
Subroutine SetPPURegisters (category: PPU)
Set PPU_CTRL, PPU_ADDR and PPU_SCROLL for the current hidden bitplane
[X]
Variable cycleCount in workspace ZP
Counts the number of CPU cycles left in the current VBlank in the NMI handler
[X]
Variable updatePaletteInNMI in workspace ZP
A flag that controls whether to send the palette data from XX3 to the PPU during NMI
[X]
Label upsc1 is local to this routine