Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish matching iTime #272

Merged
merged 2 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
71 changes: 71 additions & 0 deletions src/SB/Core/gc/iSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
83 changes: 4 additions & 79 deletions src/SB/Core/gc/iTime.cpp
Original file line number Diff line number Diff line change
@@ -1,82 +1,11 @@
#include "iTime.h"
#include "iSystem.h"

#include <types.h>
#include <dolphin.h>

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
static iTime sStartupTime;
static float32 sGameTime;

void iTimeInit()
{
Expand All @@ -92,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);
Expand Down