I have this code, where I want to change the palettes of PPU addresses $3F11 and $3F12.
Originally I had it where I set $2006 to $3F11, and then I did two writes to $2007.
However, for whatever reason (and I tried playing around with clearing and setting Carry), at some points, it will jump to $3F13 and write a value there. And I don't know why it does it.
So I tried separating $3F11 and $3F12, and it is still doing it. At some random point, it will write a value to $3F13, even though there is clearly no code making that happen.
I know that the register $2007 has a quirk to it, so I was wondering if that is what is causing the problem.
If it helps any, the code is when you press a button, it changes the palette of the character.
(I don't have it shown in the code, but just before the code, I have a LDA $2002 and a BPL (wait for Vblank), and after the code a LDA #$20 and #$00 written to $2006 to reset the PPU)
:61E3:A9 3F LDA #$3F
:61E5:8D 06 20 STA $2006 = #$13
:61E8:A9 11 LDA #$11
:61EA:8D 06 20 STA $2006 = #$13
:61ED:A6 5F LDX $005F = #$02
:61EF:BD 10 62 LDA $6210,X @ $6212 = #$30
:61F2:8D 07 20 STA $2007 = #$20
:61F5:A9 3F LDA #$3F
:61F7:8D 06 20 STA $2006 = #$13
:61FA:A9 12 LDA #$12
:61FC:8D 06 20 STA $2006 = #$13
:61FF:BD 18 62 LDA $6218,X @ $621A = #$2C
:6202:8D 07 20 STA $2007 = #$20
If anyone has any ideas, feel free to let me know. Thanks.