Reading along the Nerdy Nights tutorial (awesome guide) I came across this:
http://nintendoage.com/forum/messagevie ... adid=33274
It then shows 4 passes of 256 reads/writes.
Isn't a full screen 960 bytes? 32 x 30 tiles?
I ended up writing something that loops 256 3 times, then finishes off the stragglers for the remaining 192 bytes.
My code is not as clean looking but it seems to load it all in. Curious if I'm doing this properly. Looking at the nametable viewer seems correct.
Quote:
When we are using nested loops to copy entire backgrounds we want 256 x 4 = 1KB
http://nintendoage.com/forum/messagevie ... adid=33274
It then shows 4 passes of 256 reads/writes.
Isn't a full screen 960 bytes? 32 x 30 tiles?
I ended up writing something that loops 256 3 times, then finishes off the stragglers for the remaining 192 bytes.
Code:
LDA $2002 ; read PPU status to reset the high/low latch
LDA #$20
STA $2006 ; write the high byte of $2000 address
LDA #$00
STA $2006 ; write the low byte of $2000 address
LDA #LOW(StartNametable)
STA pointerLow
LDA #HIGH(StartNametable)
STA pointerHigh
LDX #$00
LDY #$00
LoadStartNametableLoop:
LDA [pointerLow], y
STA $2007
INY
; nametable data will hold one full screen, or 32*30 bytes
; we need to check our x counter to determine when to stop reading "chunks" of 256 bytes
; if x is 3 we have already read 3 * 256 bytes, and only need the straggler 192 bytes
; otherwise we keep reading until y flips again (another 256 bytes read)
CPX #$03
BNE StartNametableChunk
CPY #$C0
BNE LoadStartNametableLoop
JMP LoadStartNametableDone
StartNametableChunk:
CPY #$00
BNE LoadStartNametableLoop
INC pointerHigh
INX
JMP LoadStartNametableLoop
LoadStartNametableDone:
LDA #$20
STA $2006 ; write the high byte of $2000 address
LDA #$00
STA $2006 ; write the low byte of $2000 address
LDA #LOW(StartNametable)
STA pointerLow
LDA #HIGH(StartNametable)
STA pointerHigh
LDX #$00
LDY #$00
LoadStartNametableLoop:
LDA [pointerLow], y
STA $2007
INY
; nametable data will hold one full screen, or 32*30 bytes
; we need to check our x counter to determine when to stop reading "chunks" of 256 bytes
; if x is 3 we have already read 3 * 256 bytes, and only need the straggler 192 bytes
; otherwise we keep reading until y flips again (another 256 bytes read)
CPX #$03
BNE StartNametableChunk
CPY #$C0
BNE LoadStartNametableLoop
JMP LoadStartNametableDone
StartNametableChunk:
CPY #$00
BNE LoadStartNametableLoop
INC pointerHigh
INX
JMP LoadStartNametableLoop
LoadStartNametableDone:
My code is not as clean looking but it seems to load it all in. Curious if I'm doing this properly. Looking at the nametable viewer seems correct.