Someone sent me a message about getting an error #6 with my blargg_ppu_tests_2005.09.15b VRAM access tests, "Palette read should also read VRAM into read buffer". I'm posting my answer here since it might benefit others. The problem is likely that the emulator isn't treating a palette read as a normal read regarding the internal read buffer (I don't have my notes right now so this is all from memory):
Shown in code:
Code:
Normal VRAM read: VRAM ---> buffer -> CPU
Palette VRAM read: VRAM ---> buffer
Palette ---> CPU
Palette VRAM read: VRAM ---> buffer
Palette ---> CPU
Shown in code:
Code:
; Normal VRAM access
lda #$10 ; VADDR = $1000
sta $2006
lda #$00
sta $2006
lda $2007 ; A = ?? (previous contents of internal buffer)
lda $2007 ; A = VRAM at $1000
; Palette VRAM access
lda #$3F ; VADDR = $3F12 (palette area)
sta $2006
lda #$12
sta $2006
lda $2007 ; A = Palette RAM at $12
lda $2007 ; A = Palette RAM at $13
lda #$10 ; VADDR = $1000
sta $2006
lda #$00
sta $2006
lda $2007 ; A = VRAM at $2F13 (filled earlier)
lda $2007 ; A = VRAM at $1000
lda #$10 ; VADDR = $1000
sta $2006
lda #$00
sta $2006
lda $2007 ; A = ?? (previous contents of internal buffer)
lda $2007 ; A = VRAM at $1000
; Palette VRAM access
lda #$3F ; VADDR = $3F12 (palette area)
sta $2006
lda #$12
sta $2006
lda $2007 ; A = Palette RAM at $12
lda $2007 ; A = Palette RAM at $13
lda #$10 ; VADDR = $1000
sta $2006
lda #$00
sta $2006
lda $2007 ; A = VRAM at $2F13 (filled earlier)
lda $2007 ; A = VRAM at $1000