I'd like to implement a check for the pause key (F1) within my game.
The problem is that I am not sure where to put it ...
My first thought was to implement it in the interrupt management routine :
 Check for a strike on F1 (Yes : goto , No : goto )
 Disable interrupts, loop to wait for a second strike to get out of pause, enable interrupts
 Rest of the interrupt management routine ...
But if I do it that way, when the 2nd strike on pause releases the interrupts and jump to the main interrupt management, I am completely out of sync with VBLANK, which means that I can be interrupted by VBLANK within the interrupt management routine ... Which is a mess.
The other solution I thought of is to implement the check for F1 within a global wait routine which I uses quite frequently during the game in order to slow down the CPU to sync with the player actions. But I am well aware that although I need frequently this wait routine at this stage of development, it will probably vanishes progressively as I increase the CPU load ...
Any remarks ?
Is there another solution ?
PS : I need the pause check not for the sake of it, but rather to implement a developer menu which will allow me to navigate thru the game, change levels as I want and view VRAM pages
I'd check for the pause key at the same time as checking other inputs. If pause key is pressed, set a 'lol i'm paused' variable, and check that at the start of every frame.
incognito ergo sum (109)
Yes, I would do the same as hap.
BTW, when I read the title I thought it was about the PAUSE button. For the sake of curiosity: what does the PAUSE button do?
remember that is not just to STOP
is also to STOP de current note/sound playing
and then when restart, continue playing the music.
@Hap : your solution is as good as mine, since it means to check something within the interrupt management routine, be it the "I'm paused" flag or the F1 key itself.
@flyguille : yes, I realize that, and there will be code to deal with that, but at the moment, I do not have a music engine yet.
In the meantime I continued to implement the check for pause as I explained it, and I must say that everything goes well ... Even if I get out of sync with VBLANK, it does not show on screen and it does not freeze the computer.
hm, ok... Anyway, to sync with vblank, set up a temporary INT hook to a routine with just a RET in it, then acknowledge vdp interrupt (by reading status reg) and do ei -> halt. After that, set the INT hook back to what it was and go back to the game loop.
Don't you have an account yet? Become an MSX-friend and register an account!