There may have been a thread in the past about this subject but I was not able to find it. Sorry if my message may not be clear since I'm recovering from a weekend battling with a stronger cold and it may affect how well I explain my issue.
I'm investigating how to have multiple states for the main loop. For the NMI, I decided to test today with the vector pointing in RAM so I can change the address anytime and it's working fine. This way it removes many possible if statement in the NMI and you just point to the right function for the right state.
For the main loop, there is no such vector. So I'm trying to check how can I change the main loop state. For now I will think out a loud to see what I could figure out.
One way is you have a main loop that first decide in which state it is. Then it will call a function for the current state (game intro, game menu, in game etc) . This function will do it's proper init then enter in it's own infinite loop. The only problem I see here is how do I quit that specific state without an IF statement on every loop and how do I enter a temporary state (ex: entering sub menu in-game for example) without again an if statement in on every loop.
How do people approach this problem? For now it's not yet a problem for me since I'm still developing the engine code but it will soon become an issue.
Any comment on the subject will be appreciated.
I'm investigating how to have multiple states for the main loop. For the NMI, I decided to test today with the vector pointing in RAM so I can change the address anytime and it's working fine. This way it removes many possible if statement in the NMI and you just point to the right function for the right state.
For the main loop, there is no such vector. So I'm trying to check how can I change the main loop state. For now I will think out a loud to see what I could figure out.
One way is you have a main loop that first decide in which state it is. Then it will call a function for the current state (game intro, game menu, in game etc) . This function will do it's proper init then enter in it's own infinite loop. The only problem I see here is how do I quit that specific state without an IF statement on every loop and how do I enter a temporary state (ex: entering sub menu in-game for example) without again an if statement in on every loop.
How do people approach this problem? For now it's not yet a problem for me since I'm still developing the engine code but it will soon become an issue.
Any comment on the subject will be appreciated.