It is currently Tue Sep 18, 2018 9:00 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Improved VBL/NMI tests
PostPosted: Wed Mar 05, 2008 10:22 am 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
I've rewritten my VBL/NMI tests that test timing and behavior of the VBL flag and NMI. These should cover almost everything, including obscure details. A failed test now prints more information, which makes finding the cause easier. Most of the timing tests run on successive PPU clocks and print the result from each, so you can see a graphical display of timing and easily diagnose off-by-one errors visually. Full ca65 source is included.

nes_vbl_nmi_tests.zip

Example output for NMI suppression test:

01 N-
02 N-
03 N-
04 --
05 -V
06 -V
07 NV
08 NV
09 NV

The test reads $2002 and shows whether NMI occurred normally that frame, and whether the VBL flag was set in the byte read from $2002. It runs multiple times, each one PPU clock later. The left column is the relative time of the $2002 read, in PPU clocks. The N means NMI occurred (wasn't suppressed), and V means the VBL flag was set in the byte read from $2002.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 05, 2008 11:16 am 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1849
Excellent! Great work, blargg! Thanks.

I'm currently hitting a snag on the last even_odd_timing test. It's reporting all zeros (which I'm assuming means no cycles are being skipped).

I'm under the impression that dot 340 (the last dot) of the pre-render scanline is the cycle that is skipped. However after examining your source it looks like you're disabling the PPU around dot 260.

I tried shifting around which dot I skip in my emu to try and get closer to finding out which dot determines whether or not to skip a cycle... but I've tried several guesses and still get the test reporting all zeros (so I don't know if I'm close or not).

I don't suppose you know which dot I should be looking at? The readme and source don't seem to indicate any details on the behavior.

Thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 05, 2008 12:27 pm 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
Good point, it's hard to know how to correct the even/odd time. Here's a rewrite that tells whether it's too soon or too late. It tests both enabling BG and disabling BG, though the timings are the same. To get my emulator passing, I had to set the time around PPU clock 339 of scanline 20.

10-even_odd_timing.nes.zip

Quote:
The readme and source don't seem to indicate any details on the behavior.

Yep, this is just tests, no documentation of correct behavior (beyond what the test should give).


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 05, 2008 5:36 pm 
Offline
User avatar

Joined: Thu Mar 24, 2005 3:17 pm
Posts: 355
(had some trouble with the even_odd_timing test too, got it working eventually though)
Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 24, 2008 10:08 am 
Offline

Joined: Mon Sep 27, 2004 11:51 pm
Posts: 101
These are the results I am getting:

Image

I would assume my NMI code is broken given that I have not touched it in ages. Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 28, 2008 6:53 am 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3153
Location: Brazil
My problem is here, I'm stuck. :(
Image

Some help would be very appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 28, 2008 2:31 pm 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
Hyde, looks like your NMI is occurring 2 clocks too early. Take a look at the source to 05-nmi_timing.

Fx3, could be that you are clearing the VBL flag one PPU clock too late. Take a look at the source to 07-nmi_on_timing.

EDIT: bold-faced word that should be read carefully.


Last edited by blargg on Sat Jun 28, 2008 4:34 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 28, 2008 3:27 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3153
Location: Brazil
It seems a CPU timing bug, but I'm unable to trace your test code. When I delay the VBL clearing by 1 cycle, it gives an error.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 01, 2008 12:09 am 
Offline

Joined: Mon Sep 27, 2004 11:51 pm
Posts: 101
blargg wrote:
Hyde, looks like your NMI is occurring 2 clocks too early. Take a look at the source to 05-nmi_timing.

Fx3, could be that you are clearing the VBL flag one PPU clock too late. Take a look at the source to 07-nmi_on_timing.

EDIT: bold-faced word that should be read carefully.


Hey blargg! Long time no see.

Would it be possible for one to assemble each test individually? Should I use ca65?

I definitely need to look at the source for more info on this, but does this 5th test rely on any "tricky" NMI behavior?

Thanks for your reply.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 01, 2008 2:32 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3153
Location: Brazil
Yes, I'd like a single version of the test too, since this one uses bankswitch and I cannot trace it as I would like.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 01, 2008 3:25 pm 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
Let me know if you have trouble following the readme.
nes_vbl_nmi_tests.zip/source/readme.txt wrote:
To assemble a test with ca65, use the following commands:

ca65 -I common -o rom.o source_filename_here.s
ld65 -C nes.cfg rom.o -o rom.nes
your_favorite_nes_emulator rom.nes


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 01, 2008 6:18 pm 
Offline
Formerly Fx3
User avatar

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3153
Location: Brazil
Wheee... thank you! ;)

EDIT: nmi_on_timing problem has been fixed.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group