gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > pause fuction

#39970 - ghost Leinad - Thu Apr 14, 2005 12:45 am

anybody knows how to do a simple pause function????

really simple i know..i'm just lazy to figure out myself

thank you very much

#39972 - poslundc - Thu Apr 14, 2005 1:10 am

Finite state machines

Dan.

#40019 - sgeos - Thu Apr 14, 2005 2:48 pm

This will pause everything including music.
Code:

void pause(void)
{
   while (1)
   {
      vsync();
      update_keys();
      if (start_pressed())
         return;
   }
}


-Brendan

#40028 - Lord Graga - Thu Apr 14, 2005 4:39 pm

Why should it pause music? it's usually interrupt-controlled.

#40068 - Lupin - Thu Apr 14, 2005 10:02 pm

but doesnt the buffers for sound need to be filled at vblank? If you use vblank IRQ for filling the buffers sound would of course still work... but if you use vblank IRQ to handle all game code the pause function wouldn't work :)

if you use IRQs that need to be paused too then just disable them at the beginning of the pause function and enable them before the pause function returns.
_________________
Team Pokeme
My blog and PM ASM tutorials

#40071 - sajiimori - Thu Apr 14, 2005 10:23 pm

Step 1: Make it so one function call does all the work that you don't want to happen during pause.

Step 2: Don't call it while paused.

Step 3: There is no step 3.

#40278 - ghost Leinad - Sun Apr 17, 2005 12:34 am

lo...the vsync() works just fine...thanks