Copying large chunks in the outside NMI loop. -DareToAsk

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
klonoa
Posts: 59
Joined: Mon Nov 21, 2011 3:53 pm

Copying large chunks in the outside NMI loop. -DareToAsk

Post by klonoa » Wed Jun 03, 2020 9:45 am

So I'm taking "There are no stupid questions" to heart here.

Right now my game works like this:

Code: Select all

EndlessLoop:
   JMP EndlessLoop

NMI:
    JSR updategraphics
    JSR  ReadControllers
    JSR UpdateGame
    JSR PlaysoundandMusic
    RTI
My first question is if this is usually how it's done and are there any uses for the endlessloop?

As of late I can think of one, I have 500 bytes of rom I want to copy over into ram.
This is non timing sensitive so instead of copying it over in the nmi risking the nmi to interrupt the previous nmi interrupt (Is there a word for this?)
I would use a pointer in ram to a function in the endless loop that would copy stuff until it's done.
If there's nothing to copy the pointer would simply point to EndlessLoop again.
Of course this would require some more variables for the copy process but this isn't that crazy of an idea right?

calima
Posts: 1125
Joined: Tue Oct 06, 2015 10:16 am

Re: Copying large chunks in the outside NMI loop. -DareToAsk

Post by calima » Wed Jun 03, 2020 10:08 am

Yes, some games use the main thread for decompression or other such slow tasks, while their logic is in NMI like you describe.

klonoa
Posts: 59
Joined: Mon Nov 21, 2011 3:53 pm

Re: Copying large chunks in the outside NMI loop. -DareToAsk

Post by klonoa » Fri Jun 05, 2020 6:23 am

I found the answer, on the nesdev wiki no less. :oops:
https://wiki.nesdev.com/w/index.php/NMI_thread

Post Reply