Trouble with vram_access Test Rom.

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
albailey
Posts: 177
Joined: Thu Jul 13, 2006 3:15 pm

Trouble with vram_access Test Rom.

Post by albailey »

When running vram_access.nes which is one of blargg's test roms, I fail with an error 6.

I understand what the test rom is doing. I just do not understand why the behaviour should be that way.

Basically the step I am failing does the following:

1) stores the value $9A to PPU $2F12 using 2007
2) read 2007 (which would be $2F13)
3) Reads from PPU palette 3F12 (I do not manipulate the read buffer here)
4) Read from PPU $2F13 (this will return the read buffer from step 2 and load whatever is in $2F13 into the read buffer).

I do not understand the activity around steps 1 and 2.
When I write to $2007 doesnt it increment the ppu address, so that if I then read from $2007 it will load the read buffer with the next location?

Nintendulator passes the test rom, and a log of what it is doing around that region:

Code: Select all


E0EC  20 33 E0  JSR $E033                       A:12 X:01 Y:00 P:25 SP:F1 CYC: 82 SL:245
E033  48        PHA                             A:12 X:01 Y:00 P:25 SP:EF CYC:100 SL:245
E034  A9 2F     LDA #$2F                        A:12 X:01 Y:00 P:25 SP:EE CYC:109 SL:245
E036  8D 06 20  STA $2006 = FF                  A:2F X:01 Y:00 P:25 SP:EE CYC:115 SL:245
E039  68        PLA                             A:2F X:01 Y:00 P:25 SP:EE CYC:127 SL:245
E03A  8D 06 20  STA $2006 = FF                  A:12 X:01 Y:00 P:25 SP:EF CYC:139 SL:245
E03D  60        RTS                             A:12 X:01 Y:00 P:25 SP:EF CYC:151 SL:245
E0EF  A9 9A     LDA #$9A                        A:12 X:01 Y:00 P:25 SP:F1 CYC:169 SL:245
E0F1  8D 07 20  STA $2007 = FF                  A:9A X:01 Y:00 P:A5 SP:F1 CYC:175 SL:245
E0F4  AD 07 20  LDA $2007 = FF                  A:9A X:01 Y:00 P:A5 SP:F1 CYC:187 SL:245

E0F7  A9 3F     LDA #$3F                        A:12 X:01 Y:00 P:25 SP:F1 CYC:199 SL:245
E0F9  8D 06 20  STA $2006 = FF                  A:3F X:01 Y:00 P:25 SP:F1 CYC:205 SL:245
E0FC  A9 12     LDA #$12                        A:3F X:01 Y:00 P:25 SP:F1 CYC:217 SL:245
E0FE  8D 06 20  STA $2006 = FF                  A:12 X:01 Y:00 P:25 SP:F1 CYC:223 SL:245
E101  AD 07 20  LDA $2007 = FF                  A:12 X:01 Y:00 P:25 SP:F1 CYC:235 SL:245
E104  A9 13     LDA #$13                        A:30 X:01 Y:00 P:25 SP:F1 CYC:247 SL:245
E106  20 33 E0  JSR $E033                       A:13 X:01 Y:00 P:25 SP:F1 CYC:253 SL:245
E033  48        PHA                             A:13 X:01 Y:00 P:25 SP:EF CYC:271 SL:245

E034  A9 2F     LDA #$2F                        A:13 X:01 Y:00 P:25 SP:EE CYC:280 SL:245
E036  8D 06 20  STA $2006 = FF                  A:2F X:01 Y:00 P:25 SP:EE CYC:286 SL:245
E039  68        PLA                             A:2F X:01 Y:00 P:25 SP:EE CYC:298 SL:245
E03A  8D 06 20  STA $2006 = FF                  A:13 X:01 Y:00 P:25 SP:EF CYC:310 SL:245
E03D  60        RTS                             A:13 X:01 Y:00 P:25 SP:EF CYC:322 SL:245
E109  AD 07 20  LDA $2007 = FF                  A:13 X:01 Y:00 P:25 SP:F1 CYC:340 SL:245
E10C  C9 9A     CMP #$9A                        A:9A X:01 Y:00 P:A5 SP:F1 CYC: 11 SL:246
SUCCESS
Unfortunately my does not behave the same. Can anyone explain the actions around steps 1,2

Here's my output (based on what are apparently wrong assumptions)

Code: Select all


E0EC  20 33 E0  JSR $E033                       A:12 X:00 Y:00 P:35 SP:FD CYC: 91 SL:4
E033  48        PHA                             A:12 X:00 Y:00 P:35 SP:FB CYC:109 SL:4
E034  A9 2F     LDA #$2F                        A:12 X:00 Y:00 P:35 SP:FA CYC:118 SL:4
E036  8D 06 20  STA $2006 = 9A                  A:2F X:00 Y:00 P:35 SP:FA CYC:124 SL:4
E039  68        PLA                             A:2F X:00 Y:00 P:35 SP:FA CYC:136 SL:4
E03A  8D 06 20  STA $2006 = 9A                  A:12 X:00 Y:00 P:35 SP:FB CYC:148 SL:4
E03D  60        RTS                             A:12 X:00 Y:00 P:35 SP:FB CYC:160 SL:4
E0EF  A9 9A     LDA #$9A                        A:12 X:00 Y:00 P:35 SP:FD CYC:178 SL:4
E0F1  8D 07 20  STA $2007 = 12                  A:9A X:00 Y:00 P:B5 SP:FD CYC:184 SL:4
E0F4  AD 07 20  LDA $2007 = 12                  A:9A X:00 Y:00 P:B5 SP:FD CYC:196 SL:4

E0F7  A9 3F     LDA #$3F                        A:12 X:00 Y:00 P:35 SP:FD CYC:208 SL:4
E0F9  8D 06 20  STA $2006 = 12                  A:3F X:00 Y:00 P:35 SP:FD CYC:214 SL:4
E0FC  A9 12     LDA #$12                        A:3F X:00 Y:00 P:35 SP:FD CYC:226 SL:4
E0FE  8D 06 20  STA $2006 = 12                  A:12 X:00 Y:00 P:35 SP:FD CYC:232 SL:4
E101  AD 07 20  LDA $2007 = 34                  A:12 X:00 Y:00 P:35 SP:FD CYC:244 SL:4
E104  A9 13     LDA #$13                        A:34 X:00 Y:00 P:35 SP:FD CYC:256 SL:4 (diff)
E106  20 33 E0  JSR $E033                       A:13 X:00 Y:00 P:35 SP:FD CYC:262 SL:4
E033  48        PHA                             A:13 X:00 Y:00 P:35 SP:FB CYC:280 SL:4

E034  A9 2F     LDA #$2F                        A:13 X:00 Y:00 P:35 SP:FA CYC:289 SL:4
E036  8D 06 20  STA $2006 = 34                  A:2F X:00 Y:00 P:35 SP:FA CYC:295 SL:4
E039  68        PLA                             A:2F X:00 Y:00 P:35 SP:FA CYC:307 SL:4
E03A  8D 06 20  STA $2006 = 34                  A:13 X:00 Y:00 P:35 SP:FB CYC:319 SL:4
E03D  60        RTS                             A:13 X:00 Y:00 P:35 SP:FB CYC:331 SL:4
E109  AD 07 20  LDA $2007 = 34                  A:13 X:00 Y:00 P:35 SP:FD CYC:  8 SL:5
E10C  C9 9A     CMP #$9A                        A:34 X:00 Y:00 P:35 SP:FD CYC: 20 SL:5 (diff)
FAILURE
Thanks,
Al
ReaperSMS
Posts: 174
Joined: Sun Sep 19, 2004 11:07 pm

Post by ReaperSMS »

http://nesdev.com/bbs/viewtopic.php?t=567
blargg's third post.
Reading from $2007 when the VRAM address is $3fxx will fill the internal read buffer with the contents at VRAM address $3fxx, in addition to reading the palette RAM.
So reading from palette entry 3F12 should return that value direct to the CPU, but the PPU should also read vram address $3F12, which is a mirror of $2F12, into the read buffer.
albailey
Posts: 177
Joined: Thu Jul 13, 2006 3:15 pm

Post by albailey »

Perfect.
Thank you very much.

Al
Post Reply