sgdk
timer.h File Reference

Timer support. More...

Go to the source code of this file.

Defines

#define SUBTICKPERSECOND   76800
 Number of subtick per second.
#define TICKPERSECOND   300
 Number of tick per second.
#define TIMEPERSECOND   256
 Time sub division per second.
#define MAXTIMER   16
 Maximum number of timer.

Functions

u32 getSubTick ()
 Returns elapsed subticks from console reset.
u32 getTick ()
 Returns elapsed ticks from console reset.
u32 getTime (u16 fromTick)
 Returns elapsed time from console reset.
fix32 getTimeAsFix32 (u16 fromTick)
 Returns elapsed time in second from console reset.
void startTimer (u16 numTimer)
 Start internal timer (0 <= numtimer < MAXTIMER)
u32 getTimer (u16 numTimer, u16 restart)
 Get elapsed subticks for specified timer.
void waitSubTick (u32 subtick)
 Wait for a certain amount of subticks.
void waitTick (u32 tick)
 Wait for a certain amount of ticks.
void waitMs (u32 ms)
 Wait for a certain amount of millisecond.

Variables

vu32 vtimer

Detailed Description

Timer support.

Author:
Stephane Dallongeville
Date:
08/2011

This unit provides basic timer functions (useful for profiling).
This unit uses V-Int to count frame so disabling V-Int will make timer methods to not work anymore.


Function Documentation

u32 getSubTick ( )

Returns elapsed subticks from console reset.

Returns elapsed subticks from console reset (1/76800 second based).
WARNING: this function isn't accurate because of the VCounter rollback.

u32 getTick ( )

Returns elapsed ticks from console reset.

Returns elapsed ticks from console reset (1/300 second based).

u32 getTime ( u16  fromTick)

Returns elapsed time from console reset.

Parameters:
fromTickChoose tick or sub tick (more accurate) calculation.

Returns elapsed time from console reset (1/256 second based).

fix32 getTimeAsFix32 ( u16  fromTick)

Returns elapsed time in second from console reset.

Parameters:
fromTickChoose tick or sub tick (more accurate) calculation.

Returns elapsed time in second from console reset.
Value is returned as fix32.

u32 getTimer ( u16  numTimer,
u16  restart 
)

Get elapsed subticks for specified timer.

Parameters:
numTimerTimer number (0-MAXTIMER)
restartRestart timer if TRUE

Returns elapsed subticks from last call to startTimer(numTimer).

void startTimer ( u16  numTimer)

Start internal timer (0 <= numtimer < MAXTIMER)

Parameters:
numTimerTimer number (0-MAXTIMER)
void waitMs ( u32  ms)

Wait for a certain amount of millisecond.

Parameters:
msNumber of millisecond to wait for.

WARNING: ~3.33 ms based timer so use 4 ms as minimum wait value.
Also you cannot use this method from the V-Int callback (the method will return immediatly).

void waitSubTick ( u32  subtick)

Wait for a certain amount of subticks.

Parameters:
subtickNumber of subtick to wait for.

WARNING: this function isn't accurate because of the VCounter rollback.
Also you cannot use this method from the V-Int callback (the method will return immediatly).

void waitTick ( u32  tick)

Wait for a certain amount of ticks.

Parameters:
tickNumber of tick to wait for.

WARNING: 5/6 (PAL/NTSC) ticks based timer so use 5/6 ticks as minimum wait value.
Also you cannot use this method from the V-Int callback (the method will return immediatly).

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines