From 883323d05f1e1b2d2321f621930a17ab0d2ef89c Mon Sep 17 00:00:00 2001 From: tgsm Date: Sat, 22 Jun 2024 08:00:20 -0500 Subject: [PATCH 1/2] Move some iSystem functions from iTime --- src/SB/Core/gc/iSystem.cpp | 71 ++++++++++++++++++++++++++++++++++++++ src/SB/Core/gc/iTime.cpp | 71 -------------------------------------- 2 files changed, 71 insertions(+), 71 deletions(-) diff --git a/src/SB/Core/gc/iSystem.cpp b/src/SB/Core/gc/iSystem.cpp index 3a1f5ae87..0ce4bd34f 100644 --- a/src/SB/Core/gc/iSystem.cpp +++ b/src/SB/Core/gc/iSystem.cpp @@ -173,3 +173,74 @@ void _rwDolphinHeapFree(void* __ptr) } } } + +int32 iGetMinute() +{ + OSTime ticks = OSGetTime(); + OSCalendarTime td; + OSTicksToCalendarTime(ticks, &td); + return td.min; +} + +int32 iGetHour() +{ + OSTime ticks = OSGetTime(); + OSCalendarTime td; + OSTicksToCalendarTime(ticks, &td); + return td.hour; +} + +int32 iGetDay() +{ + OSTime ticks = OSGetTime(); + OSCalendarTime td; + OSTicksToCalendarTime(ticks, &td); + return td.mday; +} + +int32 iGetMonth() +{ + OSTime ticks = OSGetTime(); + OSCalendarTime td; + OSTicksToCalendarTime(ticks, &td); + return td.mon + 1; +} + +#if 0 +// Template for future use. +char* iGetCurrFormattedDate(char* input) +{ +} + +#endif + +#if 0 +// WIP. +char* iGetCurrFormattedTime(char* input) +{ + OSTime ticks = OSGetTime(); + OSCalendarTime td; + OSTicksToCalendarTime(ticks, &td); + bool pm = false; + // STUFF. + char* ret = input; + // STUFF. + if (pm) + { + ret[8] = 'P'; + ret[9] = '.'; + ret[10] = 'M'; + ret[11] = '.'; + } + else + { + ret[8] = 'A'; + ret[9] = '.'; + ret[10] = 'M'; + ret[11] = '.'; + } + ret[12] = '\0'; + return ret + (0xd - (int32)input); +} + +#endif diff --git a/src/SB/Core/gc/iTime.cpp b/src/SB/Core/gc/iTime.cpp index 2bbee1973..6498f136f 100644 --- a/src/SB/Core/gc/iTime.cpp +++ b/src/SB/Core/gc/iTime.cpp @@ -7,77 +7,6 @@ extern iTime sStartupTime; extern float32 sGameTime; extern float32 lbl_803CE1D8; -int32 iGetMinute() -{ - OSTime ticks = OSGetTime(); - OSCalendarTime td; - OSTicksToCalendarTime(ticks, &td); - return td.min; -} - -int32 iGetHour() -{ - OSTime ticks = OSGetTime(); - OSCalendarTime td; - OSTicksToCalendarTime(ticks, &td); - return td.hour; -} - -int32 iGetDay() -{ - OSTime ticks = OSGetTime(); - OSCalendarTime td; - OSTicksToCalendarTime(ticks, &td); - return td.mday; -} - -int32 iGetMonth() -{ - OSTime ticks = OSGetTime(); - OSCalendarTime td; - OSTicksToCalendarTime(ticks, &td); - return td.mon + 1; -} - -#if 0 -// Template for future use. -char* iGetCurrFormattedDate(char* input) -{ -} - -#endif - -#if 0 -// WIP. -char* iGetCurrFormattedTime(char* input) -{ - OSTime ticks = OSGetTime(); - OSCalendarTime td; - OSTicksToCalendarTime(ticks, &td); - bool pm = false; - // STUFF. - char* ret = input; - // STUFF. - if (pm) - { - ret[8] = 'P'; - ret[9] = '.'; - ret[10] = 'M'; - ret[11] = '.'; - } - else - { - ret[8] = 'A'; - ret[9] = '.'; - ret[10] = 'M'; - ret[11] = '.'; - } - ret[12] = '\0'; - return ret + (0xd - (int32)input); -} - -#endif - void iTimeInit() { sStartupTime = OSGetTime(); From ade6b31f2ca810ce551402375fccb739d9126899 Mon Sep 17 00:00:00 2001 From: tgsm Date: Sat, 22 Jun 2024 08:05:12 -0500 Subject: [PATCH 2/2] Finish matching iTime --- configure.py | 2 +- src/SB/Core/gc/iTime.cpp | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/configure.py b/configure.py index 5590fdf3b..73ce5b871 100644 --- a/configure.py +++ b/configure.py @@ -413,7 +413,7 @@ def Rel(lib_name: str, objects: List[Object]) -> Dict[str, Any]: Object(NonMatching, "SB/Core/gc/iScrFX.cpp"), Object(NonMatching, "SB/Core/gc/iSnd.cpp"), Object(NonMatching, "SB/Core/gc/iSystem.cpp"), - Object(NonMatching, "SB/Core/gc/iTime.cpp"), + Object(Matching, "SB/Core/gc/iTime.cpp"), Object(NonMatching, "SB/Core/gc/ngcrad3d.c"), Object(Matching, "SB/Game/zNPCGoals.cpp"), Object(NonMatching, "SB/Game/zNPCGoalCommon.cpp"), # wrong function order diff --git a/src/SB/Core/gc/iTime.cpp b/src/SB/Core/gc/iTime.cpp index 6498f136f..4412e6a93 100644 --- a/src/SB/Core/gc/iTime.cpp +++ b/src/SB/Core/gc/iTime.cpp @@ -1,11 +1,11 @@ #include "iTime.h" +#include "iSystem.h" #include #include -extern iTime sStartupTime; -extern float32 sGameTime; -extern float32 lbl_803CE1D8; +static iTime sStartupTime; +static float32 sGameTime; void iTimeInit() { @@ -21,15 +21,11 @@ iTime iTimeGet() return OSGetTime() - sStartupTime; } -#if 0 -// I can't seem to figure out the float operations going on here. It looks the setup is fairly right though? float32 iTimeDiffSec(iTime time) { - return (float32)time / (176 - lbl_803CE1D8); + return (float32)time / (GET_BUS_FREQUENCY() / 4); } -#endif - float32 iTimeDiffSec(iTime t0, iTime t1) { return iTimeDiffSec(t1 - t0);