There's something that came to my mind recently and I'd like to know if I'm correct:
My game switches between NMI and game logic:
When the game logic is done, a variable is set to 1 and the game logic goes into a wait loop until the variable is 0 again.
When it's 0 again, the game logic is processed for the next frame, including preparation of all the graphics updates. Then the variable is set to 1 again.
When NMI hits, it checks the variable. If it is 0, NMI is immediately left again. If the variable is 1, NMI is processed, including putting the graphics updates to PPU. Then it sets the variable to 0.
This means the game updates its graphics during vblank and does all the preparation and game logic in the time when the 240 scanlines are drawn. Just like every game is supposed to do.
But now I also wait for a sprite 0 hit. But I don't use it for a status bar, but for parallax scrolling. This means the sprite 0 is not located somewhere at the top, but right in the middle of the screen.
So, my NMI basically looks like this (pseudo code):
My question: Since the NMI function runs until it has hit sprite 0, which is in the middle of the screen, does this mean that I only have half the time for processing my game logic that I would usually have?
After all, the NMI doesn't just do its graphics updates and then returns, enabling the game logic again. It does its graphics updates, waits until half of the screen is drawn and only then returns.
If my assumption is correct, is there any way to circumvent this? Or do I have to live with the fact that my game logic time is cut in half when I use parallax scrolling with sprite 0?
How do games do this when they put the status bar at the bottom? This would mean their game logic only has the very little time when it updates the status bar since everything else was just the NMI waiting for sprite 0.
My game switches between NMI and game logic:
When the game logic is done, a variable is set to 1 and the game logic goes into a wait loop until the variable is 0 again.
When it's 0 again, the game logic is processed for the next frame, including preparation of all the graphics updates. Then the variable is set to 1 again.
When NMI hits, it checks the variable. If it is 0, NMI is immediately left again. If the variable is 1, NMI is processed, including putting the graphics updates to PPU. Then it sets the variable to 0.
This means the game updates its graphics during vblank and does all the preparation and game logic in the time when the 240 scanlines are drawn. Just like every game is supposed to do.
But now I also wait for a sprite 0 hit. But I don't use it for a status bar, but for parallax scrolling. This means the sprite 0 is not located somewhere at the top, but right in the middle of the screen.
So, my NMI basically looks like this (pseudo code):
Code:
NmiStart:
SaveRegisters
if WaitForNmi = false then goto NmiEnd
GraphicsUpdate
SetScrollingPosition upperScreen
while not Sprite0Hit do nothing
SetScrollingPosition lowerScreen
WaitForNmi = false
NmiEnd:
RestoreRegisters
SaveRegisters
if WaitForNmi = false then goto NmiEnd
GraphicsUpdate
SetScrollingPosition upperScreen
while not Sprite0Hit do nothing
SetScrollingPosition lowerScreen
WaitForNmi = false
NmiEnd:
RestoreRegisters
My question: Since the NMI function runs until it has hit sprite 0, which is in the middle of the screen, does this mean that I only have half the time for processing my game logic that I would usually have?
After all, the NMI doesn't just do its graphics updates and then returns, enabling the game logic again. It does its graphics updates, waits until half of the screen is drawn and only then returns.
If my assumption is correct, is there any way to circumvent this? Or do I have to live with the fact that my game logic time is cut in half when I use parallax scrolling with sprite 0?
How do games do this when they put the status bar at the bottom? This would mean their game logic only has the very little time when it updates the status bar since everything else was just the NMI waiting for sprite 0.