This is what I put together in order to clear the nametable then copy over some bytes. I'm wondering what improvements could be made by someone who actually knows what they are doing.
Code:
.PROC LoadBackgroundNametable
;first clear nametable ram
lda _PPUSTATUS
lda #$20
sta _PPUADDR
lda #$00
sta _PPUADDR
ldy #$00
loadBackgroundNametableClearRAMLoopY:
ldx #$00
loadBackgroundNametableClearRAMLoopX:
lda #$24
sta _PPUDATA
inx
cpx #30
bne loadBackgroundNametableClearRAMLoopX
iny
cpy #32
bne loadBackgroundNametableClearRAMLoopY
; begin copying nametable bytes
lda _PPUSTATUS
lda #$20
sta _PPUADDR
lda #$00
sta _PPUADDR
ldx #$00
loadBackgroundNametableLoop:
lda _NAMETABLE, x
sta _PPUDATA
inx
cpx #32 ; copy 32 bytes
bne loadBackgroundNametableLoop
rts
.ENDPROC
;first clear nametable ram
lda _PPUSTATUS
lda #$20
sta _PPUADDR
lda #$00
sta _PPUADDR
ldy #$00
loadBackgroundNametableClearRAMLoopY:
ldx #$00
loadBackgroundNametableClearRAMLoopX:
lda #$24
sta _PPUDATA
inx
cpx #30
bne loadBackgroundNametableClearRAMLoopX
iny
cpy #32
bne loadBackgroundNametableClearRAMLoopY
; begin copying nametable bytes
lda _PPUSTATUS
lda #$20
sta _PPUADDR
lda #$00
sta _PPUADDR
ldx #$00
loadBackgroundNametableLoop:
lda _NAMETABLE, x
sta _PPUDATA
inx
cpx #32 ; copy 32 bytes
bne loadBackgroundNametableLoop
rts
.ENDPROC