Hello! I'm working on an Arkanoid Clone for NES. I need to understand what's the best way to change the bricks tile on the background after a collision. For now I'm loading the background on the screen in this way:
Code:
LoadPlayScreen: ;load playfield screen
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( TileLevel_1 )
STA ADDR_LOW
LDA #HIGH( TileLevel_1 )
STA ADDR_HIGH
LDX #$04 ; Loop X 4 times
LDY #$00 ; Loop Y 256 times
LoadBgLvlLoop:
LDA [ ADDR_LOW ], y
STA $2007
INY
BNE LoadBgLvlLoop
; Outer loop
INC ADDR_HIGH ; increment high byte of address backg to next 256 byte chunk
DEX ; one chunk done so X = X - 1.
BNE LoadBgLvlLoop ; if X isn't zero, do again
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( TileLevel_1 )
STA ADDR_LOW
LDA #HIGH( TileLevel_1 )
STA ADDR_HIGH
LDX #$04 ; Loop X 4 times
LDY #$00 ; Loop Y 256 times
LoadBgLvlLoop:
LDA [ ADDR_LOW ], y
STA $2007
INY
BNE LoadBgLvlLoop
; Outer loop
INC ADDR_HIGH ; increment high byte of address backg to next 256 byte chunk
DEX ; one chunk done so X = X - 1.
BNE LoadBgLvlLoop ; if X isn't zero, do again
I understand that the only way to communicate with the PPU is trough $2006/$2007, so, what's the best way to change a tile on a XY position that's already on the screen? The entire tile is on the VRAM right? So can I modify a tile and update the background?
Thanks!