Error #6 in Ppu Access in Blargg's PPU Test

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
Anes
Posts: 703
Joined: Tue Dec 21, 2004 8:35 pm
Location: Mendoza, Argentina

Error #6 in Ppu Access in Blargg's PPU Test

Post by Anes »

Im asking for help since vram_access.nes throw me error #6.
According to blargg doc the error is

"Palette read should also read VRAM into read buffer"

Im using a buffer for 2007 reads, but not for Pallete addr read.
Can somebody help me?
User avatar
cpow
NESICIDE developer
Posts: 1097
Joined: Mon Oct 13, 2008 7:55 pm
Location: Minneapolis, MN
Contact:

Re: Error #6 in Ppu Access in Blargg's PPU Test

Post by cpow »

Anes wrote:Im asking for help since vram_access.nes throw me error #6.
According to blargg doc the error is

"Palette read should also read VRAM into read buffer"

Im using a buffer for 2007 reads, but not for Pallete addr read.
Can somebody help me?
Usually a quick peek at the source code for those tests will tell you what the test is expecting to be "truth" and then you should be able to step through your code while executing the test and inspect your variation of "truth".

Have you looked at the test source code yet?
Nessie
Posts: 133
Joined: Mon Sep 20, 2004 11:13 am
Location: Sweden
Contact:

Post by Nessie »

Reading $3F00-$3FFF should work just like $3000-$3EFF, i.e. a nametable byte should be put in the VRAM buffer as usual.
However, the value that is finally returned to the CPU will not be the what was previously in the VRAM buffer. Instead, it will be a value from the palette.

Something like this:

Code: Select all

read_2007:
  previously_buffered = vram_buffer
  vram_buffer = read_ppu_memory(address)
  if address >= $3F00
    return read_palette(address)
  else
    return previously_buffered
User avatar
Anes
Posts: 703
Joined: Tue Dec 21, 2004 8:35 pm
Location: Mendoza, Argentina

Post by Anes »

Code: Select all

read_2007: 
  previously_buffered = vram_buffer 
  vram_buffer = read_ppu_memory(address) 
  if address >= $3F00 
    return read_palette(address) 
  else 
    return previously_buffered 
 
Thanks for your code, but it didn't work for me I dont know why.
It's supoussed that the code explain more or less how the buffer works, but i dont get it.
Can somebody explain me how the buffer works?
ANes
User avatar
cpow
NESICIDE developer
Posts: 1097
Joined: Mon Oct 13, 2008 7:55 pm
Location: Minneapolis, MN
Contact:

Post by cpow »

Okay, here's the relevant code for the test you're failing...I annotated with comments.

Code: Select all

; Set VRAM addr to $2f00 + A
; Preserved: A, X, Y
set_vram_pos:
      pha
      lda   #$2f
      sta   $2006
      pla
      sta   $2006
      rts

...

      lda   #6;) Palette read should also read VRAM into read buffer
      sta   result
      lda   #$12
      jsr   set_vram_pos    ; sets VRAM address to $2f12
      lda   #$9a                
      sta   $2007              ; stores $9a at $2f12, increments VRAM address to $2f13
      lda   $2007              ; returns VRAM read-buffered data, and reads from $2f13 (which will not contain $9a so you'd know if you read the wrong byte back or didn't do the buffering correctly)
      lda   #$3f                ;
      sta   $2006              ; 
      lda   #$12               ;
      sta   $2006              ; the above lines set VRAM address to $3f12
      lda   $2007       ; fills buffer with VRAM hidden by palette (in this case, $9a from $2f12, because $2000-$2fff are mirrored at $3000-$3fff)
      lda   #$13        ; change back to non-palette addr to enable buffer
      jsr   set_vram_pos ; set VRAM address to $2f13
      lda   $2007            ; read from VRAM, should return $9a which is in the buffer, perform a read from VRAM $2f13, and increment VRAM address
      cmp   #$9a
      jsr   error_if_ne      ; if you didn't get $9a from that VRAM read you fail.
Post Reply