From 3166a819cf89caa720af1c5e1e1092ec04d918ae Mon Sep 17 00:00:00 2001 From: Colin Miller Date: Tue, 20 May 2025 22:43:17 -0400 Subject: [PATCH 1/3] zMain work --- src/SB/Core/x/xserializer.h | 6 +- src/SB/Game/zEntPlayerOOBState.h | 1 + src/SB/Game/zMain.cpp | 180 ++++++++++++++++++++++++++++++- src/SB/Game/zMain.h | 2 - src/SB/Game/zTalkBox.h | 3 +- 5 files changed, 183 insertions(+), 9 deletions(-) diff --git a/src/SB/Core/x/xserializer.h b/src/SB/Core/x/xserializer.h index f9b229172..a03a12d83 100644 --- a/src/SB/Core/x/xserializer.h +++ b/src/SB/Core/x/xserializer.h @@ -12,10 +12,10 @@ struct st_SERIAL_CLIENTINFO S32 actsize; }; -struct st_SERIAL_PERCID_SIZE +struct st_SERIAL_PERCID_SIZE { U32 idtag; - S32 needsize; + S32 needsize; }; struct xSerial @@ -50,7 +50,7 @@ struct xSerial void operator delete(void*); }; -void xSerialStartup(S32, st_SERIAL_PERCID_SIZE*); +S32 xSerialStartup(S32, st_SERIAL_PERCID_SIZE*); void xSerialShutdown(); void xSerialTraverse(S32 (*func)(U32 clientID, xSerial* xser)); void xSerialWipeMainBuffer(); diff --git a/src/SB/Game/zEntPlayerOOBState.h b/src/SB/Game/zEntPlayerOOBState.h index 42469d439..1bbfdaf08 100644 --- a/src/SB/Game/zEntPlayerOOBState.h +++ b/src/SB/Game/zEntPlayerOOBState.h @@ -13,6 +13,7 @@ namespace oob_state void fx_render(); void read_persistent(xSerial& s); void write_persistent(xSerial& s); + void load_settings(xIniFile& ini); float oob_timer(); diff --git a/src/SB/Game/zMain.cpp b/src/SB/Game/zMain.cpp index 882c0a69e..71a91c985 100644 --- a/src/SB/Game/zMain.cpp +++ b/src/SB/Game/zMain.cpp @@ -24,13 +24,20 @@ #include "zCamera.h" #include "zCutsceneMgr.h" #include "zEntPlayerBungeeState.h" +#include "zEntPlayerOOBState.h" +#include "zMenu.h" +#include "iTime.h" +#include "xstransvc.h" S32 percentageDone; _tagxPad* gDebugPad; -S32 sShowMenuOnBoot; +static S32 sShowMenuOnBoot; S32 gGameSfxReport; +static st_SERIAL_PERCID_SIZE* g_xser_sizeinfo; void zLedgeAdjust(zLedgeGrabParams* params); +void zMainMemCardRenderText(const char*, bool); +void RenderText(const char*, bool); void main(S32 argc, char** argv) { @@ -377,8 +384,8 @@ void zMainParseINIGlobals(xIniFile* ini) zLedgeAdjust(&globals.player.sb.ledge); bungee_state::load_settings(*ini); - //oob_state::load_settings(xIniFile&) - //ztalkbox::load_settings(*ini); + oob_state::load_settings(*ini); + ztalkbox::load_settings(*ini); { static F32 fbuf[] = { 2.0f, 0.7f, 0.35f, 0.0f }; @@ -590,10 +597,37 @@ void zLedgeAdjust(zLedgeGrabParams* params) void zMainShowProgressBar() { + S32 progBar; + size_t sVar2; + char loadingText[12]; + char auStack_cc[64]; + char acStack_8c[64]; + char formattedStr[72]; + + if (zMenuIsFirstBoot() != 0) + { + if (100 < percentageDone) + { + percentageDone = 100; + } + progBar = percentageDone / 10; + strcpy(loadingText, "Loading..."); + memset(formattedStr, 0, 0x40); + memset(acStack_8c, 0, 0x40); + strcpy(auStack_cc, loadingText); + auStack_cc[progBar] = '\0'; + sVar2 = strlen(loadingText); + memcpy(auStack_cc, acStack_8c + progBar, progBar); // 3rd arg should have progBar - sVar2 + sprintf(formattedStr, "{font=0}{h*2}{w*2}%s{color=FFFFFFFF}%s{~:c}", auStack_cc, + acStack_8c); + zMainMemCardRenderText(formattedStr, '\x01'); + percentageDone = percentageDone + 10; + } } void zMainLoop() { + iTime time; S64 t; U32* preinit; RpAtomic* modl; @@ -608,6 +642,92 @@ void zMainLoop() U32 preinit_bubble_matfx[6]; U32 preinit_shiny_models[8]; U32 preinit_ADC_models[10]; + + zMainShowProgressBar(); + xMemPushBase(); + time = iTimeGet(); + xUtil_idtag2string(0x464f4e54, 0); + iTimeDiffSec(time); + xSTPreLoadScene(0x464f4e54, NULL, 0x1); + time = iTimeGet(); + xUtil_idtag2string(0x464f4e54, 0); + iTimeDiffSec(time); + xSTQueueSceneAssets(0x464f4e54, 1); + time = iTimeGet(); + xUtil_idtag2string(0x464f4e54, 0); + iTimeDiffSec(time); + + do + { + xSTLoadStep(time); + } while (time < 1.0f); + + xSTDisconnect(0x464f4e54, 1); + time = iTimeGet(); + xUtil_idtag2string(0x464f4e54, 0); + iTimeDiffSec(time); + zMainShowProgressBar(); + xSTPreLoadScene(0x504c4154, 0, 1); + xSTQueueSceneAssets(0x504c4154, 1); + + do + { + xSTLoadStep(time); + } while (time < 1.0f); + + xSTDisconnect(0x504c4154, 1); + zMainShowProgressBar(); + iTimeGet(); + xShadowSimple_Init(); + globals.pickupTable = (zAssetPickupTable*)xSTFindAssetByType(0x5049434b, 0, 0); + // globals.pickupTable = zPickupTableInit(); + // zPickupTableInit hasnt been implemented yet + xMemPushBase(); + time = iTimeGet(); + xUtil_idtag2string(0x4d4e5534, 0); + iTimeDiffSec(time); + xSTPreLoadScene(0x4d4e5534, 0, 1); + time = iTimeGet(); + xUtil_idtag2string(0x4d4e5534, 0); + iTimeDiffSec(time); + xSTQueueSceneAssets(0x4d4e5534, 1); + time = iTimeGet(); + xUtil_idtag2string(0x4d4e5534, 0); + iTimeDiffSec(time); + do + { + xSTLoadStep(time); + } while (time < 1.0f); + xSTDisconnect(0x4d4e5534, 1); + zMainShowProgressBar(); + time = iTimeGet(); + xUtil_idtag2string(0x4d4e5534, 0); + iTimeDiffSec(time); + xMemPushBase(); + time = iTimeGet(); + xUtil_idtag2string(0x4d4e5535, 0); + iTimeDiffSec(time); + xSTPreLoadScene(0x4d4e5535, 0, 1); + time = iTimeGet(); + xUtil_idtag2string(0x4d4e5535, 0); + iTimeDiffSec(time); + xSTQueueSceneAssets(0x4d4e5535, 1); + time = iTimeGet(); + xUtil_idtag2string(0x4d4e5535, 0); + iTimeDiffSec(time); + do + { + xSTLoadStep(time); + } while (time < 1.0f); + xSTDisconnect(0x4d4e5535, 1); + zMainShowProgressBar(); + time = iTimeGet(); + xUtil_idtag2string(0x4d4e5535, 0); + iTimeDiffSec(time); + xModelInit(); + xModelPoolInit(0x20, 0x40); + xModelPoolInit(0x28, 8); + xModelPoolInit(0x38, 1); } void zMainReadINI() @@ -635,8 +755,62 @@ void zMainMemCardSpaceQuery() S32 status; } +void zMainMemCardQueryPost(S32 needed, S32 available, S32 neededFiles, S32 unk0) +{ + RwCamera* cam = 0; + RwRGBA* colour = 0; + RwInt32 clearMode = 3; + + cam = iCameraCreate(0x280, 0x1e0, 0); + RwCameraClear(cam, colour, clearMode); + RwCameraBeginUpdate(cam); + render_mem_card_no_space(needed, available, neededFiles, unk0); + RwCameraEndUpdate(cam); + RwCameraShowRaster(cam, 0, 1); + iCameraDestroy(cam); +} + +void zMainMemCardRenderText(const char* a, bool enabled) +{ + RwCamera* cam = 0; + RwRGBA* colour = 0; + RwInt32 clearMode = 3; + + cam = iCameraCreate(0x280, 0x1e0, 0); + RwCameraClear(cam, colour, clearMode); + RwCameraBeginUpdate(cam); + RenderText(a, enabled); + RwCameraEndUpdate(cam); + RwCameraShowRaster(cam, 0, 1); + iCameraDestroy(cam); +} + void zMainLoadFontHIP() { + iTime time; + + xMemPushBase(); + time = iTimeGet(); + xUtil_idtag2string(0x464f4e54, 0); + iTimeDiffSec(time); + xSTPreLoadScene(0x464f4e54, NULL, 0x1); + time = iTimeGet(); + xUtil_idtag2string(0x464f4e54, 0); + iTimeDiffSec(time); + xSTQueueSceneAssets(0x464f4e54, 1); + time = iTimeGet(); + xUtil_idtag2string(0x464f4e54, 0); + iTimeDiffSec(time); + + do + { + xSTLoadStep(time); + } while (time < 1.0f); + + xSTDisconnect(0x464f4e54, 1); + time = iTimeGet(); + xUtil_idtag2string(0x464f4e54, 0); + iTimeDiffSec(time); } void iEnvStartup() diff --git a/src/SB/Game/zMain.h b/src/SB/Game/zMain.h index c19b8f4f1..ccd77a5f7 100644 --- a/src/SB/Game/zMain.h +++ b/src/SB/Game/zMain.h @@ -5,8 +5,6 @@ #include "xIni.h" #include "xserializer.h" -st_SERIAL_PERCID_SIZE* g_xser_sizeinfo; - enum eStartupErrors { eNoError, diff --git a/src/SB/Game/zTalkBox.h b/src/SB/Game/zTalkBox.h index c27bfb787..e7c75e60c 100644 --- a/src/SB/Game/zTalkBox.h +++ b/src/SB/Game/zTalkBox.h @@ -3,6 +3,7 @@ #include "zTextBox.h" #include "zNPCTypeCommon.h" +#include "xIni.h" #include "xScene.h" @@ -83,6 +84,7 @@ struct ztalkbox : xBase static void init(); static void load(xBase& data, xDynAsset& asset, size_t); + static void load_settings(xIniFile& ini); static void update_all(xScene& s, F32 dt); static void render_all(); static void reset_all(); @@ -90,7 +92,6 @@ struct ztalkbox : xBase static void permit(U32 add_flags, U32 remove_flags); static ztalkbox* get_active(); - void start_talk(U32 textID, callback*, zNPCCommon*); // FIXME: params not verified void load(const asset_type& tasset); From bd8b0137f80d10a69c89f3c6695933376bde72b8 Mon Sep 17 00:00:00 2001 From: Colin Miller Date: Thu, 22 May 2025 13:44:39 -0400 Subject: [PATCH 2/3] review fixes --- src/SB/Game/zMain.cpp | 60 +++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/SB/Game/zMain.cpp b/src/SB/Game/zMain.cpp index e87f0199f..5d9efb3ca 100644 --- a/src/SB/Game/zMain.cpp +++ b/src/SB/Game/zMain.cpp @@ -595,14 +595,14 @@ void zMainMemLvlChkCB() void zLedgeAdjust(zLedgeGrabParams* params) { - params->animGrab *= (1.0f/30); + params->animGrab *= (1.0f / 30); params->animGrab *= (1.0f / 30); } void zMainShowProgressBar() { S32 progBar; - size_t sVar2; + size_t str; char loadingText[12]; char auStack_cc[64]; char acStack_8c[64]; @@ -620,7 +620,7 @@ void zMainShowProgressBar() memset(acStack_8c, 0, 0x40); strcpy(auStack_cc, loadingText); auStack_cc[progBar] = '\0'; - sVar2 = strlen(loadingText); + str = strlen(loadingText); memcpy(auStack_cc, acStack_8c + progBar, progBar); // 3rd arg should have progBar - sVar2 sprintf(formattedStr, "{font=0}{h*2}{w*2}%s{color=FFFFFFFF}%s{~:c}", auStack_cc, acStack_8c); @@ -650,15 +650,15 @@ void zMainLoop() zMainShowProgressBar(); xMemPushBase(); time = iTimeGet(); - xUtil_idtag2string(0x464f4e54, 0); + xUtil_idtag2string('BOOT', 0); iTimeDiffSec(time); - xSTPreLoadScene(0x464f4e54, NULL, 0x1); + xSTPreLoadScene('BOOT', NULL, 0x1); time = iTimeGet(); - xUtil_idtag2string(0x464f4e54, 0); + xUtil_idtag2string('BOOT', 0); iTimeDiffSec(time); - xSTQueueSceneAssets(0x464f4e54, 1); + xSTQueueSceneAssets('BOOT', 1); time = iTimeGet(); - xUtil_idtag2string(0x464f4e54, 0); + xUtil_idtag2string('BOOT', 0); iTimeDiffSec(time); do @@ -666,13 +666,13 @@ void zMainLoop() xSTLoadStep(time); } while (time < 1.0f); - xSTDisconnect(0x464f4e54, 1); + xSTDisconnect('BOOT', 1); time = iTimeGet(); - xUtil_idtag2string(0x464f4e54, 0); + xUtil_idtag2string('BOOT', 0); iTimeDiffSec(time); zMainShowProgressBar(); - xSTPreLoadScene(0x504c4154, 0, 1); - xSTQueueSceneAssets(0x504c4154, 1); + xSTPreLoadScene('PLAT', 0, 1); + xSTQueueSceneAssets('PLAT', 1); do { @@ -688,45 +688,45 @@ void zMainLoop() // zPickupTableInit hasnt been implemented yet xMemPushBase(); time = iTimeGet(); - xUtil_idtag2string(0x4d4e5534, 0); + xUtil_idtag2string('MNU4', 0); iTimeDiffSec(time); - xSTPreLoadScene(0x4d4e5534, 0, 1); + xSTPreLoadScene('MNU4', 0, 1); time = iTimeGet(); - xUtil_idtag2string(0x4d4e5534, 0); + xUtil_idtag2string('MNU4', 0); iTimeDiffSec(time); - xSTQueueSceneAssets(0x4d4e5534, 1); + xSTQueueSceneAssets('MNU4', 1); time = iTimeGet(); - xUtil_idtag2string(0x4d4e5534, 0); + xUtil_idtag2string('MNU4', 0); iTimeDiffSec(time); do { xSTLoadStep(time); } while (time < 1.0f); - xSTDisconnect(0x4d4e5534, 1); + xSTDisconnect('MNU4', 1); zMainShowProgressBar(); time = iTimeGet(); - xUtil_idtag2string(0x4d4e5534, 0); + xUtil_idtag2string('MNU4', 0); iTimeDiffSec(time); xMemPushBase(); time = iTimeGet(); - xUtil_idtag2string(0x4d4e5535, 0); + xUtil_idtag2string('MNU5', 0); iTimeDiffSec(time); - xSTPreLoadScene(0x4d4e5535, 0, 1); + xSTPreLoadScene('MNU5', 0, 1); time = iTimeGet(); - xUtil_idtag2string(0x4d4e5535, 0); + xUtil_idtag2string('MNU5', 0); iTimeDiffSec(time); - xSTQueueSceneAssets(0x4d4e5535, 1); + xSTQueueSceneAssets('MNU5', 1); time = iTimeGet(); - xUtil_idtag2string(0x4d4e5535, 0); + xUtil_idtag2string('MNU5', 0); iTimeDiffSec(time); do { xSTLoadStep(time); } while (time < 1.0f); - xSTDisconnect(0x4d4e5535, 1); + xSTDisconnect('MNU5', 1); zMainShowProgressBar(); time = iTimeGet(); - xUtil_idtag2string(0x4d4e5535, 0); + xUtil_idtag2string('MNU5', 0); iTimeDiffSec(time); xModelInit(); xModelPoolInit(0x20, 0x40); @@ -765,12 +765,12 @@ void zMainMemCardQueryPost(S32 needed, S32 available, S32 neededFiles, S32 unk0) RwRGBA* colour = 0; RwInt32 clearMode = 3; - cam = iCameraCreate(0x280, 0x1e0, 0); + cam = iCameraCreate(640, 480, 0); RwCameraClear(cam, colour, clearMode); RwCameraBeginUpdate(cam); render_mem_card_no_space(needed, available, neededFiles, unk0); RwCameraEndUpdate(cam); - RwCameraShowRaster(cam, 0, 1); + RwCameraShowRaster(cam, NULL, 1); iCameraDestroy(cam); } @@ -780,12 +780,12 @@ void zMainMemCardRenderText(const char* a, bool enabled) RwRGBA* colour = 0; RwInt32 clearMode = 3; - cam = iCameraCreate(0x280, 0x1e0, 0); + cam = iCameraCreate(640, 480, 0); RwCameraClear(cam, colour, clearMode); RwCameraBeginUpdate(cam); RenderText(a, enabled); RwCameraEndUpdate(cam); - RwCameraShowRaster(cam, 0, 1); + RwCameraShowRaster(cam, NULL, 1); iCameraDestroy(cam); } From 481c2b9af57e22e3567f46cc8e3ab130d5426224 Mon Sep 17 00:00:00 2001 From: Colin Miller Date: Thu, 22 May 2025 19:42:09 +0000 Subject: [PATCH 3/3] review fix 2 --- src/SB/Game/zMain.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/SB/Game/zMain.cpp b/src/SB/Game/zMain.cpp index 5d9efb3ca..ab5238744 100644 --- a/src/SB/Game/zMain.cpp +++ b/src/SB/Game/zMain.cpp @@ -683,7 +683,7 @@ void zMainLoop() zMainShowProgressBar(); iTimeGet(); xShadowSimple_Init(); - globals.pickupTable = (zAssetPickupTable*)xSTFindAssetByType(0x5049434b, 0, 0); + globals.pickupTable = (zAssetPickupTable*)xSTFindAssetByType('PLAT', 0, 0); // globals.pickupTable = zPickupTableInit(); // zPickupTableInit hasnt been implemented yet xMemPushBase(); @@ -795,15 +795,15 @@ void zMainLoadFontHIP() xMemPushBase(); time = iTimeGet(); - xUtil_idtag2string(0x464f4e54, 0); + xUtil_idtag2string('FONT', 0); iTimeDiffSec(time); - xSTPreLoadScene(0x464f4e54, NULL, 0x1); + xSTPreLoadScene('FONT', NULL, 0x1); time = iTimeGet(); - xUtil_idtag2string(0x464f4e54, 0); + xUtil_idtag2string('FONT', 0); iTimeDiffSec(time); - xSTQueueSceneAssets(0x464f4e54, 1); + xSTQueueSceneAssets('FONT', 1); time = iTimeGet(); - xUtil_idtag2string(0x464f4e54, 0); + xUtil_idtag2string('FONT', 0); iTimeDiffSec(time); do @@ -811,9 +811,9 @@ void zMainLoadFontHIP() xSTLoadStep(time); } while (time < 1.0f); - xSTDisconnect(0x464f4e54, 1); + xSTDisconnect('FONT', 1); time = iTimeGet(); - xUtil_idtag2string(0x464f4e54, 0); + xUtil_idtag2string('FONT', 0); iTimeDiffSec(time); }