puppydrum64 wrote: ↑Wed May 19, 2021 9:00 pm
I think the better reason for using INX to wrap around to 0 is to waste time to wait for the PPU to warm up, since INX takes 5 CPU cycles compared to just 2 for LDX
I honestly don't even bother with zeroing memory before PPU warmup. I wait for the PPU and zero out both the CPU and PPU memory in one swoop. Even with this delay, my first screen is drawn and main loop is going in 6 frames, which is a tenth of a second mind you. Nerdy Nights doesn't zero PPU memory, but it's (usually) a good idea to do so. My init code looks something like this:
Code: Select all
; Set stack pointer and turn off interrupts etc
LDA #$FF
BIT PPU_STATUS ; Initial NMI read. State unknown on RESET.
- ; Loop
BIT PPU_STATUS
BPL -
- ; Loop
BIT PPU_STATUS
BPL -
; Load high bytes
LDX #$24
STX PPU_ADDR
LDX #$07
STX $01
; Load low bytes
LDY #$00
STY PPU_ADDR
STY $00
TYA
- ; Loop
-- ; Loop
STA ($00), y ; $00-$FF
STA PPU_DATA
INY; $00-$FF / $00
BNE -
DEC $01; $07-$00 / $FF
BPL --
; Store $FF in sprite page
LDA #$FF
- ; Loop
STA $200, y
INY
STA $200, y
INY
INY
STA $200, y
INY
BNE -