NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
OSTime.h
1#ifndef RVL_SDK_OS_TIME_H
2#define RVL_SDK_OS_TIME_H
3#include <revolution/OS/OSHardware.h>
4#include <types.h>
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9// Time base frequency = 1/4 bus clock
10#define OS_TIME_SPEED (OS_BUS_CLOCK_SPEED / 4)
11
12// OS time -> Real time
13#define OS_TICKS_TO_SEC(x) ((x) / (OS_TIME_SPEED))
14#define OS_TICKS_TO_MSEC(x) ((x) / (OS_TIME_SPEED / 1000))
15#define OS_TICKS_TO_USEC(x) (((x) * 8) / (OS_TIME_SPEED / 125000))
16#define OS_TICKS_TO_NSEC(x) (((x) * 8000) / (OS_TIME_SPEED / 125000))
17
18// Real time -> OS time
19#define OS_SEC_TO_TICKS(x) ((x) * (OS_TIME_SPEED))
20#define OS_MSEC_TO_TICKS(x) ((x) * (OS_TIME_SPEED / 1000))
21#define OS_USEC_TO_TICKS(x) ((x) * (OS_TIME_SPEED / 125000) / 8)
22#define OS_NSEC_TO_TICKS(x) ((x) * (OS_TIME_SPEED / 125000) / 8000)
23
24// Interpret as signed to find tick delta
25#define OS_TICKS_DELTA(x, y) ((s32)x - (s32)y)
26
27typedef struct OSCalendarTime {
28 s32 sec; // at 0x0
29 s32 min; // at 0x4
30 s32 hour; // at 0x8
31 s32 mday; // at 0xC
32 s32 month; // at 0x10
33 s32 year; // at 0x14
34 s32 wday; // at 0x18
35 s32 yday; // at 0x1C
36 s32 msec; // at 0x20
37 s32 usec; // at 0x24
39
40s64 OSGetTime(void);
41u32 OSGetTick(void);
42
43s64 __OSGetSystemTime(void);
44s64 __OSTimeToSystemTime(s64 time);
45
46void OSTicksToCalendarTime(s64 time, OSCalendarTime* cal);
47s64 OSCalendarTimeToTicks(const OSCalendarTime* cal);
48
49#ifdef __cplusplus
50}
51#endif
52#endif