It is currently Mon Dec 11, 2017 2:10 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Tue Jun 27, 2017 10:02 pm 
Offline
User avatar

Joined: Wed Nov 19, 2014 9:00 am
Posts: 40
Location: Mexico
Hi NesDev, here I am bothering you again with some silly question that has been running through my head for a while now. I'm pretty sure you guys can shed some light on this.

At the start of VBLANK, the PPU asserts the NMI line, provided NMI interrupts are enabled in the 2000 reg's bit 7. But when does the PPU releases the line (at the end of VBLANK, maybe)?

In other words, how long does the NMI line remains low after being asserted?

Thank you very much in advance.

_________________
*** O-Nes-Sama emulator team ***


Top
 Profile  
 
PostPosted: Wed Jun 28, 2017 3:18 am 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2982
Location: Tampere, Finland
The wiki's timing diagram has the answer: http://wiki.nesdev.com/w/images/d/d1/Ntsc_timing.png. (Look for "Set VBlank flag" and "Clear: VBlank, ...".)

Additionally, the top bit of PPU register $2000 affects how long NMI is asserted. You can think of the CPU's NMI input as "AND" between PPU's "in VBlank" flag and bit 7 of $2000. ("NAND" if you want to think of the NMI line as active low.)

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Wed Jun 28, 2017 6:11 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19329
Location: NE Indiana, USA (NTSC)
/NMI = NMI_occured NAND NMI_enabled

  • NMI_enabled is bit 7 of the value last written to $2000.
  • NMI_occurred becomes true at the start of line 241 (291 on Dendy). It can be read as bit 7 of $2002, and it becomes false when $2002 is read or at the start of the pre-render line (261 on NTSC/RGB or 311 on PAL), whichever comes first.
  • A press of the Reset button does not clear NMI_occurred. It clears NMI_enabled only on the front-loading NES, not Famicom, Dendy, or top-loading NES.


Top
 Profile  
 
PostPosted: Wed Jun 28, 2017 8:19 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5886
Location: Canada
May also be worth pointing out that the NMI interrupt is edge triggered, unlike the IRQ interrupt, so even if it asserts for a longer period it won't keep re-entering the NMI like it would for an IRQ.

So, you can clear it early by reading $2002 but it doesn't need to be "acknowledged".


Top
 Profile  
 
PostPosted: Wed Jun 28, 2017 9:12 am 
Offline
User avatar

Joined: Wed Nov 19, 2014 9:00 am
Posts: 40
Location: Mexico
Awesome!

It's clearer than water for me now. Thank you :) !

_________________
*** O-Nes-Sama emulator team ***


Top
 Profile  
 
PostPosted: Wed Jun 28, 2017 11:00 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10164
Location: Rio de Janeiro - Brazil
rainwarrior wrote:
So, you can clear it early by reading $2002 but it doesn't need to be "acknowledged".

I for example never acknowledge NMIs. Every cycle of vblank time counts when doing dynamic VRAM updates! :mrgreen:


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google [Bot] and 7 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