tschak909 Posted June 28, 2017 Share Posted June 28, 2017 After reading the Super Mario Bros. disassembly quite thoroughly, I find myself asking what are the advantages/disadvantages to putting the whole game inside the NMI? This to me makes a lot of sense, because it's providing a very reliable way to not only trigger frame logic, but also to ensure that you're not using too many cycles (as overrun becomes very obvious.) What else can any NES coders on here provide as far as insight into this? -Thom Quote Link to comment Share on other sites More sharing options...
DEBRO Posted June 28, 2017 Share Posted June 28, 2017 (edited) Hi there, I would tend to agree. I haven't coded for the NES but have stated the same for the 7800 and 5200. A main loop seems fine for activities that aren't time bound. An NMI however guarantees you refresh with every frame. With the 7800, which handles turning off VBLANK for you, you can cause an NMI when your display physically ends and not wait for the system to do it for you. This saves cycles, as you've stated, and could give you a little more time for game logic. Edited June 28, 2017 by DEBRO Quote Link to comment Share on other sites More sharing options...
tschak909 Posted June 28, 2017 Author Share Posted June 28, 2017 Yeah, and from the disassemblies i've seen, a lot of the early NES games literally just initialize the hardware, set the NMI and then throw themselves into a never ending loop, with the game happening in the NMI using a jump engine pattern... am considering this for my Wizard of Wor port as I don't need to do anything too special... (I'm also seeing if I can do this in CC65...masochistic? perhaps.) -Thom Quote Link to comment Share on other sites More sharing options...
gauauu Posted July 1, 2017 Share Posted July 1, 2017 There are 3 valid ways to do it. If you never have a frame that takes too long, then it doesn't matter much. Really, I'm no expert, there's a lot better info if you look at the nesdev wiki. That said, my understanding of the three is: 1. All in NMI (like Mario). Downside is that if you take too long in a frame, it re-starts NMI and things get wonky. 2. All in main (other than a flag that gets triggered in NMI). If a frame takes too long, your rendering doesn't happen during vblank and you get a couple wonky frames. 3. (What the NES Dev folks are recommending these days) do game logic in main, do vblank rendering and sound updates in NMI. This way if frames take too long, the game play slows down, but music and rendering isn't impacted. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.