GP32 Reliable Timer


TheMrCul

Still Fresh
Joined
Apr 18, 2003
Messages
52
Hello everyone. I searched around on ticks and how many are per second, and it was 64 ticks per second for 66Mhtz I think, but when I tried to program a timer into my game and tested it on GeePee32 and on a real console it was very erratic, the timer only going down a second "when it felt like it".

my code looked like this:
Code:
  	if((GpTickCountGet() - timerStartingPoint) % 64 == 0)
    whatTimeIsIt--;

Could anyone tell me what I am doing wrong? Thankyou very much! :p
 
With that code you'll need to check the timer at just the right time to get the counter to tick. ie. when the count %64=0

So if you're doing lots of stuff between checking it might miss it.

a better method would be to ...
Code:
timetotick=GpTickCountGet()+64;

...

if(GpTickCountGet()>timetotick) 
{
 whatTimeIsIt--;
 timetotick=timetotick+64;
}
 
thanks very much rich it works a treat! With a bit of testing it seems 1000 is right, not 64 like I first thought though. :p
 
Back
Top