So I'm using CHR-RAM instead of ROM in my project and I want to update a tile in the pattern table on the fly. Everything is working fine except the code is updating tiles at $1110 and $1000 when I only want to update the tile at $1110. For some reason the "LDA patternDataPoLo" seems to be causing it even though it has the same value ($#10) which I checked with fceux. if I use Immediate addressing it seems to work fine and only the tile at $1110 is being updated. I know I'm missing something here but it's driving me insane. Any pointers or tips how I can debug this?
This is what I have at the start of NMI
Code: Select all
NMI:
LDA #$00
STA $2003
LDA #$02
STA $4014 ; sprite DMA from $0200
LDA isTileUpdate
BEQ @SkipTileUpdate
LDA $2002 ; read PPU status to reset the high/low latch
LDA ppuAddressHi
STA $2006 ; write the high byte of $2000 address
LDA ppuAddressLo
STA $2006 ; write the low byte of $2000 address
LDA $2007
TAY
LSR
LSR
LSR
LSR
CLC
ADC #$10
STA patternDataPoHi
TYA
AND #%00001111
ASL
ASL
ASL
ASL
STA patternDataPoLo
LDA $2002 ; read PPU status to reset the high/low latch
LDA patternDataPoHi
STA $2006 ; write the high byte of $1000 address
LDA patternDataPoLo
;LDA #$10 ;IF I USE THIS INSTEAD OF LDA patternDataPoLo then it works without a glitch
STA $2006 ; write the low byte of $1000 address
lda #%01011010
sta $2007
@SkipTileUpdate: