Page 1 of 1

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

Posted: Wed Jun 08, 2011 5:24 pm
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?

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

Posted: Wed Jun 08, 2011 5:31 pm
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?

Posted: Wed Jun 08, 2011 5:53 pm
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

Posted: Thu Jun 09, 2011 10:39 am
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?

Posted: Thu Jun 09, 2011 10:56 am
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.