I've been reading about the NMI/vblank/frames, and I came across this quote from https://wiki.nesdev.com/w/index.php/The_frame_and_NMIs :
"Now, the drawing code I'm talking about so far is stuff that is to be drawn while rendering is enabled. In your program, you can disable rendering (aka, "turn off the PPU") via $2001 (PPUMASK). If rendering is disabled, it is perfectly sane to perform drawing code at any time (even during rendering time). This, however, does not stop that clock hand from moving. Even when 'disabled'. The PPU is still moving in and out of VBlank, and NMIs will still be generated (if enabled)."
Now, I imagine at the start of your game, you're going to have NMIs and rendering disabled. Then, before enabling them, you'd set up what needs to be drawn for the first screen before the game starts proper. Then, you'd enable NMI and rendering, allowing the first screen to be drawn, and start processing the game.
However, I'm a rather confused about something regarding the above quote. After setting up the first screen, if we then enable NMI and rendering, doesn't that mean the "minute hand" could be anywhere? Say, as soon as you enable NMI and rendering after the first screen is setup, couldn't the NMI fire in the middle of handling the input/what to draw for the next screen? I'm really struggling to explain this, as you can no doubt tell, but it's bugging me to no end. Is this why you'd have some kind of "next screen ready" variable, which says whether there is another screen ready to be drawn?
Apologies for the haphazard nature of the question. I'm attempting to start trying to figure this out again after a hiatus, and I was struggling before the hiatus Trying to get an intuitive understanding of how the NMI interweaves and communicates with the main thread is something I'm finding very difficult, but I want to try and understand that as best I can first.
Thanks.
P.S. sorry for any terminology mix-ups between NMI, vblank, frame and such. Still getting my bearings.
"Now, the drawing code I'm talking about so far is stuff that is to be drawn while rendering is enabled. In your program, you can disable rendering (aka, "turn off the PPU") via $2001 (PPUMASK). If rendering is disabled, it is perfectly sane to perform drawing code at any time (even during rendering time). This, however, does not stop that clock hand from moving. Even when 'disabled'. The PPU is still moving in and out of VBlank, and NMIs will still be generated (if enabled)."
Now, I imagine at the start of your game, you're going to have NMIs and rendering disabled. Then, before enabling them, you'd set up what needs to be drawn for the first screen before the game starts proper. Then, you'd enable NMI and rendering, allowing the first screen to be drawn, and start processing the game.
However, I'm a rather confused about something regarding the above quote. After setting up the first screen, if we then enable NMI and rendering, doesn't that mean the "minute hand" could be anywhere? Say, as soon as you enable NMI and rendering after the first screen is setup, couldn't the NMI fire in the middle of handling the input/what to draw for the next screen? I'm really struggling to explain this, as you can no doubt tell, but it's bugging me to no end. Is this why you'd have some kind of "next screen ready" variable, which says whether there is another screen ready to be drawn?
Apologies for the haphazard nature of the question. I'm attempting to start trying to figure this out again after a hiatus, and I was struggling before the hiatus Trying to get an intuitive understanding of how the NMI interweaves and communicates with the main thread is something I'm finding very difficult, but I want to try and understand that as best I can first.
Thanks.
P.S. sorry for any terminology mix-ups between NMI, vblank, frame and such. Still getting my bearings.