From d8c0fbeebba261bd75af4e119a02f10187417f05 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Tue, 22 Feb 2022 19:49:42 +1000 Subject: [PATCH] Attempt to decompile formatTime --- src/game/endscreen.c | 4 ++-- src/game/hudmsg.c | 2 +- src/game/mplayer/ingame.c | 4 ++-- src/game/savebuffer.c | 36 ++++++++++++++++++++++++++++++++--- src/include/constants.h | 6 ++++++ src/include/game/savebuffer.h | 2 +- 6 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/game/endscreen.c b/src/game/endscreen.c index 566b39339..b42f6196e 100644 --- a/src/game/endscreen.c +++ b/src/game/endscreen.c @@ -347,7 +347,7 @@ char *menuTitleStageFailed(struct menuitem *item) char *soloMenuTextMissionTime(struct menuitem *item) { - formatTime(g_StringPointer, playerGetMissionTime(), 3); + formatTime(g_StringPointer, playerGetMissionTime(), TIMEPRECISION_SECONDS); strcat(g_StringPointer, "\n"); return g_StringPointer; @@ -1134,7 +1134,7 @@ char *soloMenuTextTargetTime(struct menuitem *item) return NULL; } - formatTime(g_StringPointer, time * 60, 3); + formatTime(g_StringPointer, time * 60, TIMEPRECISION_SECONDS); strcat(g_StringPointer, "\n"); return g_StringPointer; } diff --git a/src/game/hudmsg.c b/src/game/hudmsg.c index b72689f8e..2e5d4fdbe 100644 --- a/src/game/hudmsg.c +++ b/src/game/hudmsg.c @@ -426,7 +426,7 @@ glabel hudmsgRenderMissionTimer // textcolour = alpha | 0x00ff0000; // // // 208 -// formatTime(buffer, playerGetMissionTime(), 4); +// formatTime(buffer, playerGetMissionTime(), TIMEPRECISION_HUNDREDTHS); // // return textRender(gdl, &sp8c, &sp88, buffer, g_CharsNumeric, g_FontNumeric, textcolour, 0x000000a0, viGetWidth(), viGetHeight(), 0, 0); //} diff --git a/src/game/mplayer/ingame.c b/src/game/mplayer/ingame.c index d3bf612c3..7b7ea7d31 100644 --- a/src/game/mplayer/ingame.c +++ b/src/game/mplayer/ingame.c @@ -191,9 +191,9 @@ char *menutextPauseOrUnpause(s32 arg0) char *menutextMatchTime(s32 arg0) { #if PAL - formatTime(g_StringPointer, lvGetStageTime60() * 60 / 50, 3); + formatTime(g_StringPointer, lvGetStageTime60() * 60 / 50, TIMEPRECISION_SECONDS); #else - formatTime(g_StringPointer, lvGetStageTime60(), 3); + formatTime(g_StringPointer, lvGetStageTime60(), TIMEPRECISION_SECONDS); #endif return g_StringPointer; diff --git a/src/game/savebuffer.c b/src/game/savebuffer.c index 2d779344c..64ef9e95f 100644 --- a/src/game/savebuffer.c +++ b/src/game/savebuffer.c @@ -788,9 +788,6 @@ const char var7f1adba0[] = "txmul"; const char var7f1adba8[] = "depthsub"; const char var7f1adbb4[] = "rsub"; -const char var7f1adbbc[] = ":%02d"; -const char var7f1adbc4[] = "%d"; - /** * Write the specified amount of bits to the buffer, advancing the internal pointer. * @@ -1312,6 +1309,39 @@ glabel formatTime /* f0d5a78: 27bd0068 */ addiu $sp,$sp,0x68 ); +const char var7f1adbbc[] = ":%02d"; +const char var7f1adbc4[] = "%d"; + +//void formatTime(char *dst, s32 time60, s32 precision) +//{ +// s32 sp54[5]; +// bool donefirst; +// s32 len; +// s32 i; +// +// donefirst = false; +// len = 0; +// +// sp54[4] = time60 % 60 * 100 / 60; // hundredths +// sp54[0] = time60 / 60 / 60 / 60 / 24; // days +// +// time60 /= 60; +// sp54[3] = time60 % 60; // seconds +// time60 /= 60; +// sp54[2] = time60 % 60; // minutes +// time60 /= 60; +// sp54[1] = time60 % 24; // hours +// +// for (i = 0; i <= precision; i++) { +// if (donefirst) { +// len += sprintf(&dst[len], ":%02d", sp54[i]); +// } else if (sp54[i] != 0 || i >= TIMEPRECISION_MINUTES) { +// len += sprintf(&dst[len], "%d", sp54[i]); +// donefirst = true; +// } +// } +//} + #if VERSION >= VERSION_NTSC_1_0 void func0f0d5a7c(void) { diff --git a/src/include/constants.h b/src/include/constants.h index b2c5fb600..9c8977d06 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -3964,6 +3964,12 @@ #define TILETYPE_02 2 #define TILETYPE_03 3 // Chr/obj geometry +#define TIMEPRECISION_DAYS 0 +#define TIMEPRECISION_HOURS 1 +#define TIMEPRECISION_MINUTES 2 +#define TIMEPRECISION_SECONDS 3 +#define TIMEPRECISION_HUNDREDTHS 4 + #define TITLEMODE_LEGAL 0 #define TITLEMODE_CHECKCONTROLLERS 1 #define TITLEMODE_PDLOGO 2 diff --git a/src/include/game/savebuffer.h b/src/include/game/savebuffer.h index 82cc6cc37..47e2c69de 100644 --- a/src/include/game/savebuffer.h +++ b/src/include/game/savebuffer.h @@ -23,7 +23,7 @@ void func0f0d564c(u8 *data, char *dst, bool addlinebreak); void func0f0d5690(u8 *dst, char *buffer); void savebufferWriteGuid(struct savebuffer *buffer, struct fileguid *guid); void savebufferReadGuid(struct savebuffer *buffer, struct fileguid *guid); -void formatTime(char *dst, s32 time, u32 arg2); +void formatTime(char *dst, s32 time60, s32 precision); void func0f0d5a7c(void); #endif