What's wrong with #240 ?..
Oops.
Well this code was based off of just clearing the nametable with a single value..
This change should fix it:
Code:
; replace symbol names with your names..
; PPU_NAMETABLEADDRESS - where you want to write
; p - your pointer
; myData - data you want to write
; PPU_ADDRESS ; $2006
; PPU_DATA ; $2007
; set PPU address
lda #>PPU_NAMETABLEADDRESS
sta PPU_ADDRESS ; $2006
lda #<PPU_NAMETABLEADDRESS
sta PPU_ADDRESS
; nametable is 32 x 30 = 960
; this loop is 240 x 4 = 960
lda #<mydata
sta p
lda #>mydata
sta p+1
ldy #0
ldx #240
loop:
lda (p), y
sta PPU_DATA
iny
lda (p), y
sta PPU_DATA
iny
lda (p), y
sta PPU_DATA
iny
lda (p), y
sta PPU_DATA
iny
bne skip
inc p+1
skip:
dex
bne loop
Though I am liking barrym95838's code more at this point.
This idea does work well if you are just setting the nametable to a certian value:
Code:
; set PPU address
lda #>PPU_NAMETABLEADDRESS
sta PPU_ADDRESS ; $2006
lda #<PPU_NAMETABLEADDRESS
sta PPU_ADDRESS
; nametable is 32 x 30 = 960
; this loop is 240 x 4 = 960
lda #0
ldx #240
loop:
sta PPU_DATA
sta PPU_DATA
sta PPU_DATA
sta PPU_DATA
dex
bne loop