Page 1 of 1

pausing execution

Posted: Thu Jan 27, 2005 8:59 am
by Mak0
sorry for the really basic question but what would be the best method for pausing execution for, I dont know, say 3 seconds?

Posted: Thu Jan 27, 2005 9:04 am
by Lousyphreak
dont know if it helps but this is taken straight from the scummvm port im working on:

Code: Select all

uint32 getMillis()
{
   int* sec;
   int* usec;

   SifCallRpc(&client,0,0,(void*)(&rpcBuffer[0]),0,(void*)(&rpcBuffer[0]),128,0,0);
   sec = (int*) (&rpcBuffer[0]);
   usec = (int*) (&rpcBuffer[4]);
   msecs = (*sec)*1000+ (*usec)/1000;
   return msecs;
}

void delayMillis(uint msecs_time)
{
 uint32 i = getMillis();
 uint32 time = i;

 while &#40;time <= i+msecs_time&#41; &#123;
   checkSound&#40;&#41;;
   time= getMillis&#40;&#41;;    
 &#125;
 
&#125;

Posted: Thu Jan 27, 2005 9:56 am
by Mak0
wow i guess its not as simple as I hoped. theres nothing like a simple int pause() function?

Posted: Thu Jan 27, 2005 5:16 pm
by Drakonite
You could also use the EE performance counters or use vsyncs...

i.e.

Code: Select all

#define VSYNCS_PER_FRAME 60  // NTSC, you should really do detection...

for&#40;wait=0;wait<3*VSYNCS_PER_FRAME;wait++&#41;
     VSync&#40;&#41;   //replace this with a real vsync function...