Wrap tick API

This avoids to use the SDL timer API directly, and will allow to handle
generic ticks (possibly negative).
This commit is contained in:
Romain Vimont
2021-07-04 16:50:19 +02:00
parent 5524f378c8
commit ec871dd3f5
8 changed files with 58 additions and 16 deletions

20
app/src/util/tick.h Normal file
View File

@@ -0,0 +1,20 @@
#ifndef SC_TICK_H
#define SC_TICK_H
#include <stdint.h>
typedef int64_t sc_tick;
#define SC_TICK_FREQ 1000000 // microsecond
// To be adapted if SC_TICK_FREQ changes
#define SC_TICK_TO_US(tick) (tick)
#define SC_TICK_TO_MS(tick) ((tick) / 1000)
#define SC_TICK_TO_SEC(tick) ((tick) / 1000000)
#define SC_TICK_FROM_US(us) (us)
#define SC_TICK_FROM_MS(ms) ((ms) * 1000)
#define SC_TICK_FROM_SEC(sec) ((sec) * 1000000)
sc_tick
sc_tick_now(void);
#endif