Programflow

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
User avatar
opius
Posts: 4
Joined: Sun Feb 12, 2006 4:00 pm
Location: Linkoping / Sweden
Contact:

Programflow

Post by opius » Mon Feb 20, 2006 8:56 am

Every time a NMI occurs, The Processor starts from the top of my NMI routine, and works it's way down. Is it somehow possible to save the state of the processor, so next time the NMI occurs, it continues from my previous state? (let's say i had finished half my code in the NMI Interrupt). Hope you get what i mean.

tepples
Posts: 22050
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Mon Feb 20, 2006 9:20 am

Assuming that you want your NMI to be able to interrupt other code, the standard method is as follows:

Code: Select all

nmivector:
  pha
  txa
  pha
  tya
  pha
  ; do stuff here
  pla
  tay
  pla
  tax
  pla
  rti

User avatar
opius
Posts: 4
Joined: Sun Feb 12, 2006 4:00 pm
Location: Linkoping / Sweden
Contact:

-

Post by opius » Mon Feb 20, 2006 12:48 pm

But let's say i at first do nsf-playback (not sure of how much of the vblank time that uses).
And then after that i want to do my other code.. wich takes up alot of my vblank time (so there isn't enough time for both nsf and my code)
How can i prioritise my nsf, so that after the nsf-code has updated it's registers and loaded new values etc. I want the other code to be executed and stop if it's half-finished at the end of vblank.
Then in the next vblank period, nsf goes first then i want to continue with my other code where it stopped.

I hope im not asking dumb questions,or the answer to it is obvious in some doc.

tepples
Posts: 22050
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Mon Feb 20, 2006 1:09 pm

In general, in an NES NMI handler, you do video updates first and audio updates last.

Post Reply