It is currently Sat Dec 16, 2017 4:18 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun Dec 10, 2017 7:49 am 
Offline

Joined: Fri Dec 30, 2011 7:15 am
Posts: 43
Location: Sweden
I haven't been working on nes stuff for quite a while so my knowledge is super rusty... but here goes anyway.

The wiki says this about VBL / NMI:
Quote:
Reading one PPU clock before reads it as clear and never sets the flag or generates NMI for that frame. Reading on the same PPU clock or one later reads it as set, clears it, and suppresses the NMI for that frame.

I recently checked through my nes code and remembered that one of my last changes was related to this:
Code:
Before:
uint8_t Ppu::StatusRead() //2002
{
   if(scanlineV == 241 && scanlineH < 3)
   { //suppress NMI }
   [...]
}

After:
uint8_t Ppu::StatusRead() //2002
{
   if(scanlineV == 241 && scanlineH < 2) //does dot 2 really suppress?
   { //suppress NMI }
   [...]
}


I was still passing blargg's nmi suppresion test with this. This was based on testing done in visualNES. I'll attach the 4 states i saved, which reads 0x2002 at 4 different ticks near the VBL flag getting set.

Code:
nmiEnabled339 = 339,340,000 nmi happens
nmiEnabled340 = 340,000,001 nmi doesn't happen, flag not set (A=0x20)
nmiEnabled0   = 000,001,002 nmi doesn't happen, flag set     (A=0xA0)
nmiEnabled1   = 001,002,003 nmi happens


Like I said, I haven't been working on nes stuff for a while so I'd rather have someone else tell me if this stuff is faulty, the usual alignment shenanigans, wrong or right or whatever. Haha.


Attachments:
nmiSuppress.7z [4.05 KiB]
Downloaded 1 time
Top
 Profile  
 
PostPosted: Sun Dec 10, 2017 10:52 am 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3969
Note that instructions take multiple cycles to complete. Instructions like LDA abs or STA abs are 4 cycles long.
The actual read/write happens as the last cycle ends.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
PostPosted: Sun Dec 10, 2017 11:49 am 
Offline

Joined: Fri Dec 30, 2011 7:15 am
Posts: 43
Location: Sweden
Quote:
The actual read/write happens as the last cycle ends.

That's one detail I had forgotten. (one of many...)

The numbers in these lines: "339,340,000 nmi happens" are simply the dots when 2002 is on the cpu address bus... I don't actually know the exact boundaries of when a cpu cycle starts and ends, hah.
Still, I can only get visualNES to block NMIs at two dots, not three like the wiki suggests. Or am I reading it wrong?


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: Yahoo [Bot] and 5 guests


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