1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-14 13:30:47 +00:00
oot/src/code/sleep.c

29 lines
571 B
C
Raw Normal View History

#include "global.h"
2020-04-08 16:45:50 +00:00
void Sleep_Cycles(OSTime cycles) {
OSMesgQueue mq;
OSMesg msg;
OSTimer timer;
osCreateMesgQueue(&mq, &msg, OS_MESG_BLOCK);
osSetTimer(&timer, cycles, 0, &mq, NULL);
osRecvMesg(&mq, NULL, OS_MESG_BLOCK);
}
2020-04-08 16:45:50 +00:00
void Sleep_Nsec(u32 nsec) {
Sleep_Cycles(OS_NSEC_TO_CYCLES(nsec));
}
2020-04-08 16:45:50 +00:00
void Sleep_Usec(u32 usec) {
Sleep_Cycles(OS_USEC_TO_CYCLES(usec));
}
// originally "msleep"
2020-04-08 16:45:50 +00:00
void Sleep_Msec(u32 ms) {
Sleep_Cycles((ms * OS_CPU_COUNTER) / 1000ull);
}
2020-04-08 16:45:50 +00:00
void Sleep_Sec(u32 sec) {
2020-04-08 18:24:46 +00:00
Sleep_Cycles(sec * OS_CPU_COUNTER);
}