Decomp sleep.c (#293)

This commit is contained in:
Anghelo Carvajal 2021-10-11 15:56:08 -03:00 committed by GitHub
parent 565b1f7579
commit d2ce39d24b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 9 deletions

View File

@ -239,10 +239,10 @@ s32 sprintf(char* s, char* fmt, ...);
s32 PrintUtils_VPrintf(PrintCallback* pfn, const char* fmt, va_list args);
s32 PrintUtils_Printf(PrintCallback* pfn, const char* fmt, ...);
void Sleep_Cycles(OSTime time);
// void Sleep_Nsec(void);
void Sleep_Usec(s32);
void Sleep_Msec(u32 param_1);
// void Sleep_Sec(void);
void Sleep_Nsec(u32 nsec);
void Sleep_Usec(u32 usec);
void Sleep_Msec(u32 ms);
void Sleep_Sec(u32 sec);
// void __osSetCause(void);
s32 osSendMesg(OSMesgQueue* mq, OSMesg msg, s32 flags);
// void osPfsFreeBlocks(void);

View File

@ -1,11 +1,27 @@
#include "global.h"
#pragma GLOBAL_ASM("asm/non_matchings/boot/sleep/Sleep_Cycles.s")
void Sleep_Cycles(u64 time) {
OSMesgQueue mq;
OSMesg msg;
OSTimer timer;
#pragma GLOBAL_ASM("asm/non_matchings/boot/sleep/Sleep_Nsec.s")
osCreateMesgQueue(&mq, &msg, OS_MESG_BLOCK);
osSetTimer(&timer, time, 0, &mq, NULL);
osRecvMesg(&mq, NULL, OS_MESG_BLOCK);
}
#pragma GLOBAL_ASM("asm/non_matchings/boot/sleep/Sleep_Usec.s")
void Sleep_Nsec(u32 nsec) {
Sleep_Cycles(OS_NSEC_TO_CYCLES(nsec));
}
#pragma GLOBAL_ASM("asm/non_matchings/boot/sleep/Sleep_Msec.s")
void Sleep_Usec(u32 usec) {
Sleep_Cycles(OS_USEC_TO_CYCLES(usec));
}
#pragma GLOBAL_ASM("asm/non_matchings/boot/sleep/Sleep_Sec.s")
void Sleep_Msec(u32 ms) {
Sleep_Cycles((ms * OS_CPU_COUNTER) / 1000ULL);
}
void Sleep_Sec(u32 sec) {
Sleep_Cycles(sec * OS_CPU_COUNTER);
}