sgdk: timer.h File Reference

sgdk

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

Defines | Functions | Variables
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 (1/76800 second based).
void | waitTick (u32 tick)
| Wait for a certain amount of ticks (1/300 second based).
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 during VBlank (return fixed value for the whole VBlank).
This is to avoid issue with the VCounter rollback during VBlank.

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:

  fromTick | Choose 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:

  fromTick | Choose 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:

  numTimer | Timer number (0-MAXTIMER)
  restart | Restart timer if TRUE

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

void startTimer | ( | u16 | numTimer | ) |

Start internal timer (0 <= numtimer < MAXTIMER)

Parameters:

  numTimer | Timer number (0-MAXTIMER)

void waitMs | ( | u32 | ms | ) |

Wait for a certain amount of millisecond.

Parameters:

  ms | Number of millisecond to wait for.

WARNING: ~3.33 ms based timer is used when 'ms' is >= 100.

void waitSubTick | ( | u32 | subtick | ) |

Wait for a certain amount of subticks (1/76800 second based).

Parameters:

  subtick | Number of subtick to wait for.

WARNING: this function isn't accurate during VBlank (always wait until the end of VBlank) because of the VCounter rollback.

void waitTick | ( | u32 | tick | ) |

Wait for a certain amount of ticks (1/300 second based).

Parameters:

  tick | Number of tick to wait for.

WARNING: 5/6 (PAL/NTSC) ticks based timer so use 5 or 6 ticks as minimum wait value.

All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines