Check for pause within interrupt management ?

Por Metalion

Paladin (915)

Imagen del Metalion

04-02-2011, 12:10


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 :
[1] Check for a strike on F1 (Yes : goto [2], No : goto [3])
[2] Disable interrupts, loop to wait for a second strike to get out of pause, enable interrupts
[3] 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 Hannibal

Login sesión o register para postear comentarios

Por hap

Paragon (2008)

Imagen del hap

04-02-2011, 19:06

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.

Por anonymous

incognito ergo sum (109)

Imagen del anonymous

04-02-2011, 20:03

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?

Por flyguille

Prophet (3028)

Imagen del flyguille

04-02-2011, 20:15

remember that is not just to STOP
is also to STOP de current note/sound playing
and then when restart, continue playing the music.

Por Metalion

Paladin (915)

Imagen del Metalion

04-02-2011, 20:31

@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.


Por hap

Paragon (2008)

Imagen del hap

04-02-2011, 21:15

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.

My MSX profile