diff --git a/src/SB/Core/x/xModel.h b/src/SB/Core/x/xModel.h index 99a57554..36580ab3 100644 --- a/src/SB/Core/x/xModel.h +++ b/src/SB/Core/x/xModel.h @@ -63,6 +63,11 @@ struct xModelInstance } anim_coll; }; +// NOTE (Square): Theses are based on the access pattern found in zUI_Render. +// I doubt they wrote this out by hand every time, but I'm just guessing on the macro here. +#define XMODELINSTANCE_GET_SRCBLEND(inst) (((inst)->PipeFlags >> 0x8) & 0xf) +#define XMODELINSTANCE_GET_DSTBLEND(inst) (((inst)->PipeFlags >> 0xc) & 0xf) + struct xModelTag { xVec3 v; @@ -143,4 +148,4 @@ void xModel_SceneExit(RpWorld* world); xSphere* xModelGetLocalSBound(xModelInstance* model); void xModelGetBoneMat(xMat4x3& mat, const xModelInstance& model, ulong32 index); -#endif \ No newline at end of file +#endif diff --git a/src/SB/Core/x/xScrFx.h b/src/SB/Core/x/xScrFx.h index c4db68de..83c8af4d 100644 --- a/src/SB/Core/x/xScrFx.h +++ b/src/SB/Core/x/xScrFx.h @@ -11,6 +11,7 @@ void xScrFxRender(RwCamera*); void xScrFxDrawScreenSizeRectangle(); void xScrFxFade(iColor_tag* base, iColor_tag* dest, float32 seconds, void (*callback)(), int32 hold); +int32 xScrFxIsLetterbox(); void xScrFxLetterboxReset(); int32 xScrFXGlareAdd(xVec3* pos, float32 life, float32 intensity, float32 size, float32 r, float32 g, float32 b, float32 a, RwRaster* raster); diff --git a/src/SB/Game/zUI.cpp b/src/SB/Game/zUI.cpp index dbd0830d..abadc54e 100644 --- a/src/SB/Game/zUI.cpp +++ b/src/SB/Game/zUI.cpp @@ -7,14 +7,18 @@ #include "zGame.h" #include "zGameState.h" -#include "xString.h" -#include "xstransvc.h" -#include "xTRC.h" -#include "xEvent.h" -#include "xSnd.h" #include "xCounter.h" -#include "xGroup.h" #include "xDebug.h" +#include "xEvent.h" +#include "xGroup.h" +#include "xMath2.h" +#include "xScrFx.h" +#include "xSnd.h" +#include "xstransvc.h" +#include "xString.h" +#include "xTRC.h" + +#include "iMath.h" #include #include @@ -56,74 +60,19 @@ struct menuWorldInfo menuTaskInfo taskInfo[TASK_COUNT]; }; -extern float32 _787_2; -extern float32 _950_3; -extern float32 _1187_0; -extern float32 _1188; -extern float32 _1302_0; -extern float32 _1303; -extern float32 _1304; -extern float32 _1305; -extern float64 _1307; - -static const basic_rect _1261_0 = { 0, 0, 0, 0 }; - -static const char _stringBase0_54[] = ".minf\0" - ".dff\0" - "idle\0" - "KEY OFF 1 UI\0" - "KEY OFF 2 UI\0" - "KEY OFF 3 UI\0" - "KEY OFF 4 UI\0" - "KEY ON 1 UI\0" - "KEY ON 2 UI\0" - "KEY ON 3 UI\0" - "KEY ON 4 UI\0" - "MNU3 PRESS START UIF\0" - "MNU3 PRESS START 02 UIF\0" - "MNU4 CONTROL MUSIC GC/XB UIF\0" - "Menu00\0" - " \0" - "UI_LEVEL_PATSOCK\0" - "UIF_LEVEL_PATSOCK\0" - "00_SPAT_MARKER_00\0" - "STARTCAM\0" - "00_TASK_COUNTER_00\0" - "LEVEL ON UI 00\0" - "TASK NONE UI 00\0" - "TASK UI 00\0" - "TASK GOLDEN UI 00\0" - "TASK GLOW UI 00\0" - "TASK GLOW UI BOSS 00\0" - "TASK GLOW UI SMALLBOSS 00\0" - "PAUSE TASK UIF 0000\0" - "PAUSE TAKE BUS UIF\0" - "PAUSE TASK NONE UIF\0" - "PAUSE MGR UIF\0" - "TAXI CONFIRM UIF\0" - "TAXI CONFIRM GROUP\0" - "%d/%d\0" - "KS_SPAT_MARKER_01\0" - "All tasks had NULL UIs\0" - "All worlds had NULL UIs"; - static uint32 sSortedCount = 0; -extern _zUI* sSorted[768]; static RwIm2DVertex Vertex[4]; static RwImVertexIndex Index[6] = { 0, 1, 2, 0, 2, 3 }; -static xVec3 from_1259 = { 0.0f, 0.0f, -1.0f }; // todo: move to zUI_Render -static xVec3 to_1260 = { 0.0f, 0.0f, 0.0f }; // todo: move to zUI_Render - -static uint32 cKeyUIid1off; -static uint32 cKeyUIid2off; -static uint32 cKeyUIid3off; -static uint32 cKeyUIid4off; -static uint32 cKeyUIid1on; -static uint32 cKeyUIid2on; -static uint32 cKeyUIid3on; -static uint32 cKeyUIid4on; +static uint32 cKeyUIid1off = xStrHash("KEY OFF 1 UI"); +static uint32 cKeyUIid2off = xStrHash("KEY OFF 2 UI"); +static uint32 cKeyUIid3off = xStrHash("KEY OFF 3 UI"); +static uint32 cKeyUIid4off = xStrHash("KEY OFF 4 UI"); +static uint32 cKeyUIid1on = xStrHash("KEY ON 1 UI"); +static uint32 cKeyUIid2on = xStrHash("KEY ON 2 UI"); +static uint32 cKeyUIid3on = xStrHash("KEY ON 3 UI"); +static uint32 cKeyUIid4on = xStrHash("KEY ON 4 UI"); static char patsock_text_buffer[] = "##/##"; static _zUI* patsock_ui; @@ -131,209 +80,8 @@ static zUIFont* patsock_uif; static uint32 patsock_prev_world = -1; static uint32 patsock_prev_count = -1; -extern zUIMgr gUIMgr; - static float32 ushift; -// clang-format off - -/************************** PAUSE MENU ********************************* - * This array defines the angle and character that the player will start with - * for each "task" in the game. - * - * Each entry has the following format: - * - * ang, player - * - * ang - the starting angle in degrees - * player - the starting character, can be one of the following values: - * eCurrentPlayerSpongeBob (SpongeBob) - * eCurrentPlayerPatrick (Patrick) - * eCurrentPlayerSandy (Sandy) - */ -static menuWorldInfo sWorldInfo[] = -{ - // Bikini Bottom - 322, eCurrentPlayerSpongeBob, // On Top of the Pineapple - 322, eCurrentPlayerSpongeBob, // On Top of Shady Shoals - 322, eCurrentPlayerSpongeBob, // On Top of the Chum Bucket - 200, eCurrentPlayerSpongeBob, // SpongeBob's Closet - 45, eCurrentPlayerSpongeBob, // Annoy Squidward - 315, eCurrentPlayerSpongeBob, // Ambush at the Tree Dome - 190, eCurrentPlayerSpongeBob, // Infestation at the Krusty Krab - 270, eCurrentPlayerSpongeBob, // A Wall Jump in the Bucket - - // Jellyfish Fields - 180, eCurrentPlayerSpongeBob, // Top of the Hill - 55, eCurrentPlayerSpongeBob, // Cowa-Bungee! - 210, eCurrentPlayerPatrick, // Spelunking - 180, eCurrentPlayerSpongeBob, // Patrick's Dilemma - 180, eCurrentPlayerPatrick, // Navigate the Canyons and Mesas - 50, eCurrentPlayerPatrick, // Drain the Lake - 345, eCurrentPlayerSpongeBob, // Slide Leap - 105, eCurrentPlayerSpongeBob, // Defeat King Jellyfish - - // Downtown Bikini Bottom - 90, eCurrentPlayerSpongeBob, // End of the Road - 180, eCurrentPlayerSandy, // Learn Sandy's Moves - 338, eCurrentPlayerSpongeBob, // Tikis Go Boom - 180, eCurrentPlayerSandy, // Across the Rooftops - 180, eCurrentPlayerSandy, // Swingin' Sandy - 180, eCurrentPlayerSpongeBob, // Ambush in the Lighthouse - 180, eCurrentPlayerSpongeBob, // Extreme Bungee - 270, eCurrentPlayerSpongeBob, // Come Back with the Cruise Bubble - - // Goo Lagoon - 225, eCurrentPlayerSpongeBob, // King of the Castle - 300, eCurrentPlayerSpongeBob, // Connect the Towers - 260, eCurrentPlayerSpongeBob, // Save the Children - 225, eCurrentPlayerPatrick, // Over the Moat - 270, eCurrentPlayerSpongeBob, // Through the Sea Caves - 1, eCurrentPlayerPatrick, // Clean Out the Bumper Boats - 335, eCurrentPlayerPatrick, // Slip and Slide Under the Pier - 350, eCurrentPlayerSpongeBob, // Tower Bungee - - // Poseidome - -1000000000, eCurrentPlayerSpongeBob, // Rumble at the Poseidome - -1000000000, eCurrentPlayerSpongeBob, - -1000000000, eCurrentPlayerSpongeBob, - -1000000000, eCurrentPlayerSpongeBob, - -1000000000, eCurrentPlayerSpongeBob, - -1000000000, eCurrentPlayerSpongeBob, - -1000000000, eCurrentPlayerSpongeBob, - -1000000000, eCurrentPlayerSpongeBob, - - // Rock Bottom - 90, eCurrentPlayerSpongeBob, // Get to the Museum - 90, eCurrentPlayerSpongeBob, // Slip Sliding Away - 90, eCurrentPlayerSpongeBob, // Return the Museum's Art - 345, eCurrentPlayerSandy, // Swingalong Spatula - 180, eCurrentPlayerSpongeBob, // Plundering Robots in the Museum - 280, eCurrentPlayerSpongeBob, // Across the Trench of Darkness - 1, eCurrentPlayerSandy, // Lasers are Fun and Good for You - 305, eCurrentPlayerSandy, // How in Tarnation Do You Get There? - - // Mermalair - 90, eCurrentPlayerSpongeBob, // Top of the Entrance Area - 225, eCurrentPlayerSpongeBob, // Top of the Computer Area - 30, eCurrentPlayerSpongeBob, // Shut Down the Security System - 210, eCurrentPlayerPatrick, // The Funnel Machines - 180, eCurrentPlayerPatrick, // The Spinning Towers of Power - 45, eCurrentPlayerSpongeBob, // Top of the Security Tunnel - 45, eCurrentPlayerSpongeBob, // Complete the Rolling Ball Room - -1000000000, eCurrentPlayerSpongeBob, // Defeat Prawn - - // Sand Mountain - 270, eCurrentPlayerSpongeBob, // Frosty Bungee - 270, eCurrentPlayerSandy, // Top of the Lodge - 120, eCurrentPlayerSpongeBob, // Defeat Robots on Guppy Mound - 120, eCurrentPlayerSpongeBob, // Beat Mrs. Puff's Time - 130, eCurrentPlayerSpongeBob, // Defeat Robots on Flounder Hill - 130, eCurrentPlayerSpongeBob, // Beat Bubble Buddy's Time - 180, eCurrentPlayerSpongeBob, // Defeat Robots on Sand Mountain - 180, eCurrentPlayerSpongeBob, // Beat Larry's Time - - // Industrial Park - -1000000000, eCurrentPlayerSpongeBob, // Robo-Patrick Ahoy! - -1000000000, eCurrentPlayerSpongeBob, - -1000000000, eCurrentPlayerSpongeBob, - -1000000000, eCurrentPlayerSpongeBob, - -1000000000, eCurrentPlayerSpongeBob, - -1000000000, eCurrentPlayerSpongeBob, - -1000000000, eCurrentPlayerSpongeBob, - -1000000000, eCurrentPlayerSpongeBob, - - // Kelp Forest - 1, eCurrentPlayerSpongeBob, // Through the Woods - 90, eCurrentPlayerSpongeBob, // Find all the Lost Campers - 180, eCurrentPlayerPatrick, // Tiki Roundup - 138, eCurrentPlayerPatrick, // Down in the Swamp - 160, eCurrentPlayerSpongeBob, // Through the Kelp Caves - 160, eCurrentPlayerSpongeBob, // Power Crystal Crisis - 200, eCurrentPlayerSpongeBob, // Kelp Vine Slide - 200, eCurrentPlayerSpongeBob, // Beat Mermaid Man's Time - - // Flying Dutchman's Graveyard - 225, eCurrentPlayerSpongeBob, // Top of the Entrance Area - 50, eCurrentPlayerSpongeBob, // A Path through the Goo - 180, eCurrentPlayerSpongeBob, // Goo Tanker Ahoy! - 225, eCurrentPlayerSpongeBob, // Top of the Stack of Ships - 60, eCurrentPlayerSpongeBob, // Shipwreck Bungee - 250, eCurrentPlayerSpongeBob, // Destroy the Robot Ship - 250, eCurrentPlayerSpongeBob, // Get Aloft There, Matey! - 130, eCurrentPlayerSandy, // Defeat the Flying Dutchman - - // SpongeBob's Dream - 315, eCurrentPlayerSpongeBob, // Across the Dreamscape - 315, eCurrentPlayerSpongeBob, // Follow the Bouncing Ball - 180, eCurrentPlayerSandy, // Slidin' Texas Style - 70, eCurrentPlayerSandy, // Swingers Ahoy - 135, eCurrentPlayerSpongeBob, // Music is in the Ear of the Beholder - 180, eCurrentPlayerSpongeBob, // Krabby Patty Platforms - 1, eCurrentPlayerSpongeBob, // Super Bounce - 90, eCurrentPlayerSpongeBob, // Here You Go - - // Chum Bucket Lab - -1000000000, eCurrentPlayerSpongeBob, // Kah - Rah - Tae! - -1000000000, eCurrentPlayerSpongeBob, // The Small Shall Rule... or Not - -1000000000, eCurrentPlayerSpongeBob, - -1000000000, eCurrentPlayerSpongeBob, - -1000000000, eCurrentPlayerSpongeBob, - -1000000000, eCurrentPlayerSpongeBob, - -1000000000, eCurrentPlayerSpongeBob, - -1000000000, eCurrentPlayerSpongeBob, - - // Patrick - 180, eCurrentPlayerSpongeBob, // Return 10 Socks to Patrick - 180, eCurrentPlayerSpongeBob, // Return 10 Socks to Patrick - 180, eCurrentPlayerSpongeBob, // Return 10 Socks to Patrick - 180, eCurrentPlayerSpongeBob, // Return 10 Socks to Patrick - 180, eCurrentPlayerSpongeBob, // Return 10 Socks to Patrick - 180, eCurrentPlayerSpongeBob, // Return 10 Socks to Patrick - 180, eCurrentPlayerSpongeBob, // Return 10 Socks to Patrick - 180, eCurrentPlayerSpongeBob, // Return 10 Socks to Patrick - - // Mr. Krabs - 150, eCurrentPlayerSpongeBob, // Pay Mr. Krabs 3,000 Shiny Objects - 150, eCurrentPlayerSpongeBob, // Pay Mr. Krabs 3,500 Shiny Objects - 150, eCurrentPlayerSpongeBob, // Pay Mr. Krabs 4,000 Shiny Objects - 150, eCurrentPlayerSpongeBob, // Pay Mr. Krabs 4,500 Shiny Objects - 150, eCurrentPlayerSpongeBob, // Pay Mr. Krabs 5,000 Shiny Objects - 150, eCurrentPlayerSpongeBob, // Pay Mr. Krabs 5,500 Shiny Objects - 150, eCurrentPlayerSpongeBob, // Pay Mr. Krabs 6,500 Shiny Objects - 150, eCurrentPlayerSpongeBob, // Pay Mr. Krabs 7,500 Shiny Objects -}; -// clang-format on - -#define WORLD_COUNT (sizeof(sWorldInfo) / sizeof(sWorldInfo[0])) - -#define WORLD_HB 0 // Bikini Bottom -#define WORLD_JF 1 // Jellyfish Fields -#define WORLD_BB 2 // Downtown Bikini Bottom -#define WORLD_GL 3 // Goo Lagoon -#define WORLD_B1 4 // Poseidome -#define WORLD_RB 5 // Rock Bottom -#define WORLD_BC 6 // Mermalair -#define WORLD_SM 7 // Sand Mountain -#define WORLD_B2 8 // Industrial Park -#define WORLD_KF 9 // Kelp Forest -#define WORLD_GY 10 // Flying Dutchman's Graveyard -#define WORLD_DB 11 // SpongeBob's Dream -#define WORLD_B3 12 // Chum Bucket Lab -#define WORLD_PAT 13 // Patrick -#define WORLD_KRABS 14 // Mr. Krabs - -static menuWorld sWorld[WORLD_COUNT]; - -_zUI* sTakeTaxi; -_zUI* sNoneTaskDesc; -_zUI* sCurrTaskDesc; -uint32 sCurrWorld; -uint32 sCurrTask; -_zUI* sPauseManager; -_zUI* sConfirmation; -xGroup* sTaxiConfirmGrp; - namespace { void refresh_model(_zUI& ui) @@ -345,7 +93,7 @@ namespace xMat3x3 pmat, smat; ui.bound.mat = (xMat4x3*)ui.model->Mat; - ui.bound.mat->pos = _787_2; + ui.bound.mat->pos = 0.0f; sasset = ui.sasset; mat = (xMat3x3*)ui.model->Mat; @@ -407,7 +155,6 @@ void zUIMgr::Update(zScene* s, float32 dt) debug_update(*s, dt); } -#ifdef NON_MATCHING void zUIMgr::Setup(zScene* s) { const uint32 count = s->baseCount[eBaseTypeUI]; @@ -433,7 +180,6 @@ void zUIMgr::Setup(zScene* s) ui++; } } -#endif void zUIMgr::Touch(_zUI* ui) { @@ -557,7 +303,7 @@ namespace uint32 size; void* data; - data = xSTFindAsset(xStrHashCat(id, _stringBase0_54), &size); + data = xSTFindAsset(xStrHashCat(id, ".minf"), &size); if (data) { @@ -568,7 +314,7 @@ namespace if (!data) { - data = xSTFindAsset(xStrHashCat(id, _stringBase0_54 + 6), &size); + data = xSTFindAsset(xStrHashCat(id, ".dff"), &size); } if (!data) @@ -597,15 +343,15 @@ namespace xAnimPoolAlloc(&globals.sceneCur->mempool, &ui, ui.atbl, ui.model); - xAnimState* ast = xAnimTableGetState(ui.atbl, _stringBase0_54 + 11); + xAnimState* ast = xAnimTableGetState(ui.atbl, "idle"); if (ast) { xAnimSingle* single = ui.model->Anim->Single; single->State = ast; - single->Time = _787_2; - single->CurrentSpeed = _950_3; + single->Time = 0.0f; + single->CurrentSpeed = 1.0f; } } } @@ -673,14 +419,14 @@ void zUI_Init(_zUI* ent, xEntAsset* asset) } } - cKeyUIid1off = xStrHash(_stringBase0_54 + 16); - cKeyUIid2off = xStrHash(_stringBase0_54 + 29); - cKeyUIid3off = xStrHash(_stringBase0_54 + 42); - cKeyUIid4off = xStrHash(_stringBase0_54 + 55); - cKeyUIid1on = xStrHash(_stringBase0_54 + 68); - cKeyUIid2on = xStrHash(_stringBase0_54 + 80); - cKeyUIid3on = xStrHash(_stringBase0_54 + 92); - cKeyUIid4on = xStrHash(_stringBase0_54 + 104); + cKeyUIid1off = xStrHash("KEY OFF 1 UI"); + cKeyUIid2off = xStrHash("KEY OFF 2 UI"); + cKeyUIid3off = xStrHash("KEY OFF 3 UI"); + cKeyUIid4off = xStrHash("KEY OFF 4 UI"); + cKeyUIid1on = xStrHash("KEY ON 1 UI"); + cKeyUIid2on = xStrHash("KEY ON 2 UI"); + cKeyUIid3on = xStrHash("KEY ON 3 UI"); + cKeyUIid4on = xStrHash("KEY ON 4 UI"); } void zUI_Save(_zUI* ent, xSerial* s) @@ -693,7 +439,6 @@ void zUI_Load(_zUI* ent, xSerial* s) zEntLoad(ent, s); } -#ifdef NON_MATCHING void zUI_Reset(_zUI* ent) { zEntReset(ent); @@ -708,19 +453,15 @@ void zUI_Reset(_zUI* ent) // non-matching: epilogue } -#endif -#ifdef NON_MATCHING void zUI_PreUpdate(_zUI* ent, xScene*, float32) { _zUI* ui = ent; - for (int32 i = 0; i < 1; i++) + ent->uiButton = 0; + // This matches perfectly with inlining enabled + for (int32 i = 0; i < (globals.firstStartPressed ? 1 : 1); i++) { - if (globals.firstStartPressed) - { - } - _tagxPad* pad; switch (i) @@ -740,7 +481,6 @@ void zUI_PreUpdate(_zUI* ent, xScene*, float32) pad = globals.pad2; break; } - case 3: default: { pad = globals.pad3; @@ -748,7 +488,7 @@ void zUI_PreUpdate(_zUI* ent, xScene*, float32) } } - if (pad && pad->pressed && ui->uiFlags & 0x4 && (ui->uiFlags & 0x2 || ui->uiFlags & 0x1)) + if (pad && pad->pressed && ui->uiFlags & 0x8 && (ui->uiFlags & 0x2 || ui->uiFlags & 0x1)) { if (gTrcPad[0].state == TRC_PadInserted) { @@ -834,8 +574,8 @@ void zUI_PreUpdate(_zUI* ent, xScene*, float32) xTRCReset(); } } - else if (pad->pressed & 0x1 && (ui->asset->id == xStrHash(_stringBase0_54 + 116) || - ui->asset->id == xStrHash(_stringBase0_54 + 137))) + else if (pad->pressed & 0x1 && (ui->asset->id == xStrHash("MNU3 PRESS START UIF") || + ui->asset->id == xStrHash("MNU3 PRESS START 02 UIF"))) { globals.currentActivePad = i; @@ -855,7 +595,6 @@ void zUI_PreUpdate(_zUI* ent, xScene*, float32) } } } -#endif void zUI_Update(_zUI* ent, xScene*, float32 dt) { @@ -982,16 +721,15 @@ int32 iRenderQSort_Face(const void* arg1, const void* arg2) return 0; } -#ifdef NON_MATCHING void zUIRenderAll() { // non-matching: floats are epic - ushift += _1187_0; + ushift += 0.05f; - if (ushift >= _1188) + if (ushift >= 2.0f) { - ushift -= _1188; + ushift -= 2.0f; } if (!sSortedCount) @@ -1007,7 +745,7 @@ void zUIRenderAll() bool rendering_models = false; - for (int32 i = 0; i < sSortedCount; i++) + for (int32 i = 0; i < (int32)sSortedCount; i++) { if (xEntIsVisible(sSorted[i])) { @@ -1040,53 +778,201 @@ void zUIRenderAll() debug_render(); } -#endif -int32 zUIEventCB(xBase*, xBase* to, uint32 toEvent, const float32* toParam, xBase*) +void zUI_Render(xEnt* ent) { - _zUI* s = (_zUI*)to; + static xVec3 from = { 0.0f, 0.0f, -1.0f }; + static xVec3 to = { 0.0f, 0.0f, 0.0f }; - switch (toEvent) - { - case eEventVisible: + _zUI* ui = (_zUI*)ent; + if (xScrFxIsLetterbox()) { - xEntShow(s); - gUIMgr.Touch(s); - break; - } - case eEventInvisible: - { - xEntHide(s); - gUIMgr.Touch(s); - break; - } - case eEventReset: - { - zUI_Reset(s); - break; - } - case eEventUISelect: - { - if (s->id == xStrHash(_stringBase0_54 + 161)) + if (ent->id == cKeyUIid1off || ent->id == cKeyUIid2off || ent->id == cKeyUIid3off || + ent->id == cKeyUIid4off || ent->id == cKeyUIid1on || ent->id == cKeyUIid2on || + ent->id == cKeyUIid3on || ent->id == cKeyUIid4on) { - xSndPauseCategory(SND_CAT_UI, 0); + return; } - - s->uiFlags |= 0x2; - - gUIMgr.Touch(s); - - break; } - case eEventUIUnselect: + + if (ui->uiFlags & 4) { - if (s->uiFlags & 0x2) + if (xEntIsVisible(ui)) { - s->uiFlags ^= 0x2; - } + if (ui->sasset->textureID) + { + RwTexture* texture = (RwTexture*)xSTFindAsset(ui->sasset->textureID, 0); - if (s->id == xStrHash(_stringBase0_54 + 161)) - { + if (texture != NULL && texture->raster != NULL) + { + RwRenderStateSet(rwRENDERSTATETEXTURERASTER, texture->raster); + } + + RwRaster* raster = texture->raster; + uint8 r = 0xFF; + uint8 g = 0xFF; + uint8 b = 0xFF; + uint8 a = 0xFF; + float32 w = 640.0f; + float32 h = 480.0f; + + float32 u1 = ui->sasset->uva[0]; + float32 v1 = ui->sasset->uva[1]; + float32 u2 = ui->sasset->uvb[0]; + float32 v2 = ui->sasset->uvb[1]; + float32 u3 = ui->sasset->uvc[0]; + float32 v3 = ui->sasset->uvc[1]; + float32 u4 = ui->sasset->uvd[0]; + float32 v4 = ui->sasset->uvd[1]; + float32 x1 = w * ui->sasset->pos.x / w; + float32 y1 = h * ui->sasset->pos.y / h; + float32 x2 = w * (ui->sasset->pos.x + ui->sasset->dim[0]) / w; + float32 y2 = h * (ui->sasset->pos.y + ui->sasset->dim[1]) / h; + + float32 z = RwIm2DGetNearScreenZ(); + float32 cz = z; + + if ((float)iabs(z) <= 0.00001f) + { + cz = z >= 0.0f ? 0.00001f : -0.00001f; + } + + RwIm2DVertexSetIntRGBA(&Vertex[0], 0xFF, 0xFF, 0xFF, 0xFF); + RwIm2DVertexSetIntRGBA(&Vertex[1], 0xFF, 0xFF, 0xFF, 0xFF); + RwIm2DVertexSetIntRGBA(&Vertex[2], 0xFF, 0xFF, 0xFF, 0xFF); + RwIm2DVertexSetIntRGBA(&Vertex[3], 0xFF, 0xFF, 0xFF, 0xFF); + + RwIm2DVertexSetScreenX(&Vertex[0], x1); + RwIm2DVertexSetScreenY(&Vertex[0], y1); + RwIm2DVertexSetScreenZ(&Vertex[0], cz); + RwIm2DVertexSetU(&Vertex[0], u1, 0); + RwIm2DVertexSetV(&Vertex[0], v1, 0); + + RwIm2DVertexSetScreenX(&Vertex[1], x1); + RwIm2DVertexSetScreenY(&Vertex[1], y2); + RwIm2DVertexSetScreenZ(&Vertex[1], cz); + RwIm2DVertexSetU(&Vertex[1], u4, 0); + RwIm2DVertexSetV(&Vertex[1], v4, 0); + + RwIm2DVertexSetScreenX(&Vertex[2], x2); + RwIm2DVertexSetScreenY(&Vertex[2], y2); + RwIm2DVertexSetScreenZ(&Vertex[2], cz); + RwIm2DVertexSetU(&Vertex[2], u3, 0); + RwIm2DVertexSetV(&Vertex[2], v3, 0); + + RwIm2DVertexSetScreenX(&Vertex[3], x2); + RwIm2DVertexSetScreenY(&Vertex[3], y1); + RwIm2DVertexSetScreenZ(&Vertex[3], cz); + RwIm2DVertexSetU(&Vertex[3], u2, 0); + RwIm2DVertexSetV(&Vertex[3], v2, 0); + + // For some reason this is done twice. + RwIm2DVertexSetIntRGBA(&Vertex[0], 0xFF, 0xFF, 0xFF, 0xFF); + RwIm2DVertexSetIntRGBA(&Vertex[1], 0xFF, 0xFF, 0xFF, 0xFF); + RwIm2DVertexSetIntRGBA(&Vertex[2], 0xFF, 0xFF, 0xFF, 0xFF); + RwIm2DVertexSetIntRGBA(&Vertex[3], 0xFF, 0xFF, 0xFF, 0xFF); + + zRenderState(SDRS_Default); + RwRenderStateSet(rwRENDERSTATEFOGENABLE, 0); + RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA); + RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)1); + RwRenderStateSet(rwRENDERSTATESHADEMODE, (void*)rwSHADEMODEFLAT); + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, 0); + RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, Vertex, 4, Index, 6); + } + else if (ui->model != NULL) + { + // zUIAsset & a; + basic_rect r = {}; + r.x = ui->sasset->pos.x / 640.0f; + r.y = ui->sasset->pos.y / 480.0f; + r.w = ui->sasset->dim[0] / 640.0f; + r.h = ui->sasset->dim[1] / 480.0f; + + if (r.w <= 0.0f || r.h <= 0.0f) + { + return; + } + + uint32 srcblend = XMODELINSTANCE_GET_SRCBLEND(ui->model); + uint32 destblend = XMODELINSTANCE_GET_DSTBLEND(ui->model); + RwRenderStateSet(rwRENDERSTATESRCBLEND, + (void*)(srcblend ? srcblend : rwBLENDSRCALPHA)); + RwRenderStateSet(rwRENDERSTATEDESTBLEND, + (void*)(destblend ? destblend : rwBLENDINVSRCALPHA)); + + if ((ui->model->PipeFlags & 0b1100) == rwBLENDINVSRCCOLOR) + { + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, 0); + RwRenderStateSet(rwRENDERSTATEZTESTENABLE, 0); + } + + xEntSetupPipeline(ui->model); + + ui->model->Scale.assign(1.0f, 1.0f, 1.0f); + xModelRender2D(*ui->model, r, from, to); + xEntRestorePipeline(ui->model); + + if ((ui->model->PipeFlags & 0b1100) == rwBLENDINVSRCCOLOR) + { + RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)1); + RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)1); + } + } + } + } + else + { + xEntRender(ui); + } +} + +int32 zUIEventCB(xBase*, xBase* to, uint32 toEvent, const float32* toParam, xBase*) +{ + _zUI* s = (_zUI*)to; + + switch (toEvent) + { + case eEventVisible: + { + xEntShow(s); + gUIMgr.Touch(s); + break; + } + case eEventInvisible: + { + xEntHide(s); + gUIMgr.Touch(s); + break; + } + case eEventReset: + { + zUI_Reset(s); + break; + } + case eEventUISelect: + { + if (s->id == xStrHash("MNU4 CONTROL MUSIC GC/XB UIF")) + { + xSndPauseCategory(SND_CAT_UI, 0); + } + + s->uiFlags |= 0x2; + + gUIMgr.Touch(s); + + break; + } + case eEventUIUnselect: + { + if (s->uiFlags & 0x2) + { + s->uiFlags ^= 0x2; + } + + if (s->id == xStrHash("MNU4 CONTROL MUSIC GC/XB UIF")) + { xSndPauseCategory(SND_CAT_UI, 1); } @@ -1167,9 +1053,207 @@ int32 zUIEventCB(xBase*, xBase* to, uint32 toEvent, const float32* toParam, xBas return 1; } +// clang-format off + +/************************** PAUSE MENU ********************************* + * This array defines the angle and character that the player will start with + * for each "task" in the game. + * + * Each entry has the following format: + * + * ang, player + * + * ang - the starting angle in degrees + * player - the starting character, can be one of the following values: + * eCurrentPlayerSpongeBob (SpongeBob) + * eCurrentPlayerPatrick (Patrick) + * eCurrentPlayerSandy (Sandy) + */ +static menuWorldInfo sWorldInfo[] = +{ + // Bikini Bottom + 322, eCurrentPlayerSpongeBob, // On Top of the Pineapple + 322, eCurrentPlayerSpongeBob, // On Top of Shady Shoals + 322, eCurrentPlayerSpongeBob, // On Top of the Chum Bucket + 200, eCurrentPlayerSpongeBob, // SpongeBob's Closet + 45, eCurrentPlayerSpongeBob, // Annoy Squidward + 315, eCurrentPlayerSpongeBob, // Ambush at the Tree Dome + 190, eCurrentPlayerSpongeBob, // Infestation at the Krusty Krab + 270, eCurrentPlayerSpongeBob, // A Wall Jump in the Bucket + + // Jellyfish Fields + 180, eCurrentPlayerSpongeBob, // Top of the Hill + 55, eCurrentPlayerSpongeBob, // Cowa-Bungee! + 210, eCurrentPlayerPatrick, // Spelunking + 180, eCurrentPlayerSpongeBob, // Patrick's Dilemma + 180, eCurrentPlayerPatrick, // Navigate the Canyons and Mesas + 50, eCurrentPlayerPatrick, // Drain the Lake + 345, eCurrentPlayerSpongeBob, // Slide Leap + 105, eCurrentPlayerSpongeBob, // Defeat King Jellyfish + + // Downtown Bikini Bottom + 90, eCurrentPlayerSpongeBob, // End of the Road + 180, eCurrentPlayerSandy, // Learn Sandy's Moves + 338, eCurrentPlayerSpongeBob, // Tikis Go Boom + 180, eCurrentPlayerSandy, // Across the Rooftops + 180, eCurrentPlayerSandy, // Swingin' Sandy + 180, eCurrentPlayerSpongeBob, // Ambush in the Lighthouse + 180, eCurrentPlayerSpongeBob, // Extreme Bungee + 270, eCurrentPlayerSpongeBob, // Come Back with the Cruise Bubble + + // Goo Lagoon + 225, eCurrentPlayerSpongeBob, // King of the Castle + 300, eCurrentPlayerSpongeBob, // Connect the Towers + 260, eCurrentPlayerSpongeBob, // Save the Children + 225, eCurrentPlayerPatrick, // Over the Moat + 270, eCurrentPlayerSpongeBob, // Through the Sea Caves + 1, eCurrentPlayerPatrick, // Clean Out the Bumper Boats + 335, eCurrentPlayerPatrick, // Slip and Slide Under the Pier + 350, eCurrentPlayerSpongeBob, // Tower Bungee + + // Poseidome + -1000000000, eCurrentPlayerSpongeBob, // Rumble at the Poseidome + -1000000000, eCurrentPlayerSpongeBob, + -1000000000, eCurrentPlayerSpongeBob, + -1000000000, eCurrentPlayerSpongeBob, + -1000000000, eCurrentPlayerSpongeBob, + -1000000000, eCurrentPlayerSpongeBob, + -1000000000, eCurrentPlayerSpongeBob, + -1000000000, eCurrentPlayerSpongeBob, + + // Rock Bottom + 90, eCurrentPlayerSpongeBob, // Get to the Museum + 90, eCurrentPlayerSpongeBob, // Slip Sliding Away + 90, eCurrentPlayerSpongeBob, // Return the Museum's Art + 345, eCurrentPlayerSandy, // Swingalong Spatula + 180, eCurrentPlayerSpongeBob, // Plundering Robots in the Museum + 280, eCurrentPlayerSpongeBob, // Across the Trench of Darkness + 1, eCurrentPlayerSandy, // Lasers are Fun and Good for You + 305, eCurrentPlayerSandy, // How in Tarnation Do You Get There? + + // Mermalair + 90, eCurrentPlayerSpongeBob, // Top of the Entrance Area + 225, eCurrentPlayerSpongeBob, // Top of the Computer Area + 30, eCurrentPlayerSpongeBob, // Shut Down the Security System + 210, eCurrentPlayerPatrick, // The Funnel Machines + 180, eCurrentPlayerPatrick, // The Spinning Towers of Power + 45, eCurrentPlayerSpongeBob, // Top of the Security Tunnel + 45, eCurrentPlayerSpongeBob, // Complete the Rolling Ball Room + -1000000000, eCurrentPlayerSpongeBob, // Defeat Prawn + + // Sand Mountain + 270, eCurrentPlayerSpongeBob, // Frosty Bungee + 270, eCurrentPlayerSandy, // Top of the Lodge + 120, eCurrentPlayerSpongeBob, // Defeat Robots on Guppy Mound + 120, eCurrentPlayerSpongeBob, // Beat Mrs. Puff's Time + 130, eCurrentPlayerSpongeBob, // Defeat Robots on Flounder Hill + 130, eCurrentPlayerSpongeBob, // Beat Bubble Buddy's Time + 180, eCurrentPlayerSpongeBob, // Defeat Robots on Sand Mountain + 180, eCurrentPlayerSpongeBob, // Beat Larry's Time + + // Industrial Park + -1000000000, eCurrentPlayerSpongeBob, // Robo-Patrick Ahoy! + -1000000000, eCurrentPlayerSpongeBob, + -1000000000, eCurrentPlayerSpongeBob, + -1000000000, eCurrentPlayerSpongeBob, + -1000000000, eCurrentPlayerSpongeBob, + -1000000000, eCurrentPlayerSpongeBob, + -1000000000, eCurrentPlayerSpongeBob, + -1000000000, eCurrentPlayerSpongeBob, + + // Kelp Forest + 1, eCurrentPlayerSpongeBob, // Through the Woods + 90, eCurrentPlayerSpongeBob, // Find all the Lost Campers + 180, eCurrentPlayerPatrick, // Tiki Roundup + 138, eCurrentPlayerPatrick, // Down in the Swamp + 160, eCurrentPlayerSpongeBob, // Through the Kelp Caves + 160, eCurrentPlayerSpongeBob, // Power Crystal Crisis + 200, eCurrentPlayerSpongeBob, // Kelp Vine Slide + 200, eCurrentPlayerSpongeBob, // Beat Mermaid Man's Time + + // Flying Dutchman's Graveyard + 225, eCurrentPlayerSpongeBob, // Top of the Entrance Area + 50, eCurrentPlayerSpongeBob, // A Path through the Goo + 180, eCurrentPlayerSpongeBob, // Goo Tanker Ahoy! + 225, eCurrentPlayerSpongeBob, // Top of the Stack of Ships + 60, eCurrentPlayerSpongeBob, // Shipwreck Bungee + 250, eCurrentPlayerSpongeBob, // Destroy the Robot Ship + 250, eCurrentPlayerSpongeBob, // Get Aloft There, Matey! + 130, eCurrentPlayerSandy, // Defeat the Flying Dutchman + + // SpongeBob's Dream + 315, eCurrentPlayerSpongeBob, // Across the Dreamscape + 315, eCurrentPlayerSpongeBob, // Follow the Bouncing Ball + 180, eCurrentPlayerSandy, // Slidin' Texas Style + 70, eCurrentPlayerSandy, // Swingers Ahoy + 135, eCurrentPlayerSpongeBob, // Music is in the Ear of the Beholder + 180, eCurrentPlayerSpongeBob, // Krabby Patty Platforms + 1, eCurrentPlayerSpongeBob, // Super Bounce + 90, eCurrentPlayerSpongeBob, // Here You Go + + // Chum Bucket Lab + -1000000000, eCurrentPlayerSpongeBob, // Kah - Rah - Tae! + -1000000000, eCurrentPlayerSpongeBob, // The Small Shall Rule... or Not + -1000000000, eCurrentPlayerSpongeBob, + -1000000000, eCurrentPlayerSpongeBob, + -1000000000, eCurrentPlayerSpongeBob, + -1000000000, eCurrentPlayerSpongeBob, + -1000000000, eCurrentPlayerSpongeBob, + -1000000000, eCurrentPlayerSpongeBob, + + // Patrick + 180, eCurrentPlayerSpongeBob, // Return 10 Socks to Patrick + 180, eCurrentPlayerSpongeBob, // Return 10 Socks to Patrick + 180, eCurrentPlayerSpongeBob, // Return 10 Socks to Patrick + 180, eCurrentPlayerSpongeBob, // Return 10 Socks to Patrick + 180, eCurrentPlayerSpongeBob, // Return 10 Socks to Patrick + 180, eCurrentPlayerSpongeBob, // Return 10 Socks to Patrick + 180, eCurrentPlayerSpongeBob, // Return 10 Socks to Patrick + 180, eCurrentPlayerSpongeBob, // Return 10 Socks to Patrick + + // Mr. Krabs + 150, eCurrentPlayerSpongeBob, // Pay Mr. Krabs 3,000 Shiny Objects + 150, eCurrentPlayerSpongeBob, // Pay Mr. Krabs 3,500 Shiny Objects + 150, eCurrentPlayerSpongeBob, // Pay Mr. Krabs 4,000 Shiny Objects + 150, eCurrentPlayerSpongeBob, // Pay Mr. Krabs 4,500 Shiny Objects + 150, eCurrentPlayerSpongeBob, // Pay Mr. Krabs 5,000 Shiny Objects + 150, eCurrentPlayerSpongeBob, // Pay Mr. Krabs 5,500 Shiny Objects + 150, eCurrentPlayerSpongeBob, // Pay Mr. Krabs 6,500 Shiny Objects + 150, eCurrentPlayerSpongeBob, // Pay Mr. Krabs 7,500 Shiny Objects +}; +// clang-format on + +#define WORLD_COUNT (sizeof(sWorldInfo) / sizeof(sWorldInfo[0])) + +#define WORLD_HB 0 // Bikini Bottom +#define WORLD_JF 1 // Jellyfish Fields +#define WORLD_BB 2 // Downtown Bikini Bottom +#define WORLD_GL 3 // Goo Lagoon +#define WORLD_B1 4 // Poseidome +#define WORLD_RB 5 // Rock Bottom +#define WORLD_BC 6 // Mermalair +#define WORLD_SM 7 // Sand Mountain +#define WORLD_B2 8 // Industrial Park +#define WORLD_KF 9 // Kelp Forest +#define WORLD_GY 10 // Flying Dutchman's Graveyard +#define WORLD_DB 11 // SpongeBob's Dream +#define WORLD_B3 12 // Chum Bucket Lab +#define WORLD_PAT 13 // Patrick +#define WORLD_KRABS 14 // Mr. Krabs + +static menuWorld sWorld[WORLD_COUNT]; + +_zUI* sTakeTaxi; +_zUI* sNoneTaskDesc; +_zUI* sCurrTaskDesc; +uint32 sCurrWorld; +uint32 sCurrTask; +_zUI* sPauseManager; +_zUI* sConfirmation; +xGroup* sTaxiConfirmGrp; + // This function only matches when using string literals for some reason. // Need to wait until all strings are decompiled. -#ifdef NON_MATCHING void zUI_ParseINI(xIniFile* ini) { char itemName[16]; @@ -1227,7 +1311,6 @@ void zUI_ParseINI(xIniFile* ini) } } } -#endif static _zUI* findUI(zScene* s, uint32 id) { @@ -1312,31 +1395,19 @@ void zUI_ScenePortalSetToCurrentLevel(zScene* zsc) sCurrTask = 0; } -#ifndef NON_MATCHING -static void init_patsocks(zScene* zsc); -#else static void init_patsocks(zScene* zsc) { - patsock_ui = findUI(zsc, xStrHash(_stringBase0_54 + 199)); - patsock_uif = findUIFont(zsc, xStrHash(_stringBase0_54 + 216)); + patsock_ui = findUI(zsc, xStrHash("UI_LEVEL_PATSOCK")); + patsock_uif = findUIFont(zsc, xStrHash("UIF_LEVEL_PATSOCK")); // non-matching: instruction order and registers patsock_text_buffer[0] = '\0'; patsock_prev_world = -1; patsock_prev_count = -1; } -#endif -#ifdef NON_MATCHING void zUI_ScenePortalInit(zScene* zsc) { - uint32 i, j; - char c, c2; - char tempString[32]; - uint32 uiID; - _zUI* ui; - uint32 id; - init_patsocks(zsc); if (zsc->baseCount[eBaseTypeUI] == 0) @@ -1360,9 +1431,16 @@ void zUI_ScenePortalInit(zScene* zsc) sWorld[WORLD_PAT].numTasks = 8; sWorld[WORLD_KRABS].numTasks = 8; + uint32 i, j; + char c, c2; + char tempString[32]; + uint32 uiID; + _zUI* ui; + uint32 id; + for (i = 0; i < WORLD_COUNT; i++) { - strcpy(tempString, _stringBase0_54 + 234); + strcpy(tempString, "00_SPAT_MARKER_00"); tempString[0] = sWorld[i].worldPrefix[0]; tempString[1] = sWorld[i].worldPrefix[1]; @@ -1382,35 +1460,34 @@ void zUI_ScenePortalInit(zScene* zsc) if (sWorld[i].task[j].levelSuffix[0] == '0' && sWorld[i].task[j].levelSuffix[1] == '0') { sWorld[i].task[j].portal.passet = NULL; + continue; } - else - { - sWorld[i].task[j].portalAsset.assetCameraID = xStrHash(_stringBase0_54 + 252); - sWorld[i].task[j].portalAsset.assetMarkerID = xStrHash(tempString); - sWorld[i].task[j].portalAsset.ang = sWorldInfo[i].taskInfo[j].ang; - if (i == WORLD_PAT || i == WORLD_KRABS) - { - sWorld[i].task[j].portalAsset.sceneID = - (sWorld[i].task[j].levelSuffix[1] << 24) | - (sWorld[i].task[j].levelSuffix[0] << 16) | 'BH'; - } - else - { - sWorld[i].task[j].portalAsset.sceneID = - (sWorld[i].task[j].levelSuffix[1] << 24) | - (sWorld[i].task[j].levelSuffix[0] << 16) | (sWorld[i].worldPrefix[1] << 8) | - sWorld[i].worldPrefix[0]; - } + sWorld[i].task[j].portalAsset.assetCameraID = xStrHash("STARTCAM"); + sWorld[i].task[j].portalAsset.assetMarkerID = xStrHash(tempString); + sWorld[i].task[j].portalAsset.ang = sWorldInfo[i].taskInfo[j].ang; - sWorld[i].task[j].portal.passet = &sWorld[i].task[j].portalAsset; + if (i == WORLD_PAT || i == WORLD_KRABS) + { + sWorld[i].task[j].portalAsset.sceneID = (sWorld[i].task[j].levelSuffix[1] << 24) | + (sWorld[i].task[j].levelSuffix[0] << 16) | + 'BH'; } + else + { + sWorld[i].task[j].portalAsset.sceneID = (sWorld[i].task[j].levelSuffix[1] << 24) | + (sWorld[i].task[j].levelSuffix[0] << 16) | + (sWorld[i].worldPrefix[1] << 8) | + sWorld[i].worldPrefix[0]; + } + + sWorld[i].task[j].portal.passet = &sWorld[i].task[j].portalAsset; } } for (i = 0; i < WORLD_COUNT; i++) { - strcpy(tempString, _stringBase0_54 + 261); + strcpy(tempString, "00_TASK_COUNTER_00"); tempString[0] = sWorld[i].worldPrefix[0]; tempString[1] = sWorld[i].worldPrefix[1]; @@ -1435,7 +1512,7 @@ void zUI_ScenePortalInit(zScene* zsc) } } - strcpy(tempString, _stringBase0_54 + 280); + strcpy(tempString, "LEVEL ON UI 00"); c = '1'; @@ -1455,7 +1532,7 @@ void zUI_ScenePortalInit(zScene* zsc) sWorld[i].uiSelected = findUI(zsc, id); } - strcpy(tempString, _stringBase0_54 + 295); + strcpy(tempString, "TASK NONE UI 00"); c = '1'; @@ -1480,7 +1557,7 @@ void zUI_ScenePortalInit(zScene* zsc) } } - strcpy(tempString, _stringBase0_54 + 311); + strcpy(tempString, "TASK UI 00"); c = '1'; @@ -1505,7 +1582,7 @@ void zUI_ScenePortalInit(zScene* zsc) } } - strcpy(tempString, _stringBase0_54 + 322); + strcpy(tempString, "TASK GOLDEN UI 00"); c = '1'; @@ -1530,7 +1607,7 @@ void zUI_ScenePortalInit(zScene* zsc) } } - strcpy(tempString, _stringBase0_54 + 340); + strcpy(tempString, "TASK GLOW UI 00"); c = '1'; @@ -1558,11 +1635,11 @@ void zUI_ScenePortalInit(zScene* zsc) } } - strcpy(tempString, _stringBase0_54 + 356); + strcpy(tempString, "TASK GLOW UI BOSS 00"); c = '1'; - for (j = 0; j < TASK_COUNT; j++) + for (j = 0; j < TASK_COUNT_BOSS; j++) { if (c > '9') { @@ -1586,11 +1663,11 @@ void zUI_ScenePortalInit(zScene* zsc) } } - strcpy(tempString, _stringBase0_54 + 377); + strcpy(tempString, "TASK GLOW UI SMALLBOSS 00"); c = '1'; - for (j = 0; j < TASK_COUNT; j++) + for (j = 0; j < TASK_COUNT_SMALLBOSS; j++) { if (c > '9') { @@ -1614,7 +1691,7 @@ void zUI_ScenePortalInit(zScene* zsc) } } - strcpy(tempString, _stringBase0_54 + 403); + strcpy(tempString, "PAUSE TASK UIF 0000"); c = '1'; @@ -1629,16 +1706,17 @@ void zUI_ScenePortalInit(zScene* zsc) tempString[16] = c; c++; + c2 = '1'; for (j = 0; j < sWorld[i].numTasks; j++) { - if (c > '9') + if (c2 > '9') { - c = '0'; + c2 = '0'; tempString[17]++; } - tempString[18] = c; - c++; + tempString[18] = c2; + c2++; id = xStrHash(tempString); @@ -1646,25 +1724,24 @@ void zUI_ScenePortalInit(zScene* zsc) } } - id = xStrHash(_stringBase0_54 + 423); + id = xStrHash("PAUSE TAKE BUS UIF"); sTakeTaxi = findUIFont(zsc, id); - id = xStrHash(_stringBase0_54 + 442); + id = xStrHash("PAUSE TASK NONE UIF"); sNoneTaskDesc = findUIFont(zsc, id); - id = xStrHash(_stringBase0_54 + 462); + id = xStrHash("PAUSE MGR UIF"); sPauseManager = findUIFont(zsc, id); sPauseManager->eventFunc = zUIPortalEventCB; - id = xStrHash(_stringBase0_54 + 476); + id = xStrHash("TAXI CONFIRM UIF"); sConfirmation = findUIFont(zsc, id); - id = xStrHash(_stringBase0_54 + 493); + id = xStrHash("TAXI CONFIRM GROUP"); sTaxiConfirmGrp = (xGroup*)zSceneFindObject(id); zUI_ScenePortalSetToCurrentLevel(zsc); } -#endif static void hideWorld() { @@ -1720,9 +1797,6 @@ static void enable_ui(_zUI* ui) } } -#ifndef NON_MATCHING -static void refresh_patsocks(uint32 world); -#else static void refresh_patsocks(uint32 world) { uint32 count = globals.player.Inv_PatsSock[world]; @@ -1754,7 +1828,7 @@ static void refresh_patsocks(uint32 world) max = 99; } - sprintf(patsock_text_buffer, _stringBase0_54 + 512, count, max); + sprintf(patsock_text_buffer, "%d/%d", count, max); enable_ui(patsock_ui); enable_ui(patsock_uif); @@ -1766,7 +1840,6 @@ static void refresh_patsocks(uint32 world) } } } -#endif void zUI_PortalToKrabs(uint32 taskNum) { @@ -1775,7 +1848,7 @@ void zUI_PortalToKrabs(uint32 taskNum) int32 c2 = sWorld[WORLD_B2].task[0].counter->count; char tempString[32]; - strcpy(tempString, _stringBase0_54 + 518); + strcpy(tempString, "KS_SPAT_MARKER_01"); if (c1 != 2 && c2 != 2) { @@ -1799,88 +1872,93 @@ void zUI_PortalToKrabs(uint32 taskNum) passet->assetMarkerID = xStrHash(tempString); } -#ifdef NON_MATCHING void zUI_ScenePortalUpdate() { for (uint32 i = 0; i < WORLD_COUNT; i++) { - if (sWorld[i].uiSelected && xEntIsVisible(sWorld[i].uiSelected)) + if (!sWorld[i].uiSelected) + { + continue; + } + if (!xEntIsVisible(sWorld[i].uiSelected)) { - refresh_patsocks(i); - hideWorld(); - showWorld(i); + continue; + } - sCurrWorld = i; + refresh_patsocks(i); + hideWorld(); + showWorld(i); - for (uint32 j = 0; j < sWorld[i].numTasks; j++) + sCurrWorld = i; + + for (uint32 j = 0; j < sWorld[i].numTasks; j++) + { + _zUI* select = sWorld[i].task[j].uiSelected; + + if (select && xEntIsVisible(select)) { - _zUI* select = sWorld[i].task[j].uiSelected; + sCurrTask = j; - if (select && xEntIsVisible(select)) + if (sCurrTaskDesc) { - sCurrTask = j; + xEntHide(sCurrTaskDesc); + } - if (sCurrTaskDesc) - { - xEntHide(sCurrTaskDesc); - } + sCurrTaskDesc = sWorld[i].task[j].uiTaskDesc; - sCurrTaskDesc = sWorld[i].task[j].uiTaskDesc; + if (sCurrTaskDesc) + { + xEntShow(sCurrTaskDesc); + } + if (sWorld[i].task[j].counter->count != 0 || globals.player.g.CheatAlwaysPortal) + { + xEntHide(sNoneTaskDesc); + xEntShow(sTakeTaxi); + } + else + { if (sCurrTaskDesc) { - xEntShow(sCurrTaskDesc); - } - - if (sWorld[i].task[j].counter->count != 0 || globals.player.g.CheatAlwaysPortal) - { - xEntHide(sNoneTaskDesc); - xEntShow(sTakeTaxi); - } - else - { - if (sCurrTaskDesc) - { - xEntHide(sCurrTaskDesc); - } - - xEntShow(sNoneTaskDesc); - xEntHide(sTakeTaxi); + xEntHide(sCurrTaskDesc); } - if (select->uiButton & XPAD_BUTTON_X && xEntIsVisible(sConfirmation) && - sWorld[i].task[j].portal.passet && - (sWorld[i].uiSelected->idx > 0 || globals.player.g.CheatAlwaysPortal)) - { - if (i == WORLD_KRABS) - { - zUI_PortalToKrabs(j); - } - - zSceneSwitch(&sWorld[i].task[j].portal, 1); - zGameStateSwitchEvent(eEventDispatcher_SetGameState_SceneSwitch); + xEntShow(sNoneTaskDesc); + xEntHide(sTakeTaxi); + } - gPendingPlayer = sWorldInfo[i].taskInfo[j].player; - } - else if (select->uiButton & XPAD_BUTTON_X && !xEntIsVisible(sConfirmation) && - sWorld[i].task[j].portal.passet && - (sWorld[i].uiSelected->idx > 0 || globals.player.g.CheatAlwaysPortal)) + if (select->uiButton & XPAD_BUTTON_X && xEntIsVisible(sConfirmation) && + sWorld[i].task[j].portal.passet && + (sWorld[i].task[j].counter->count > 0 || globals.player.g.CheatAlwaysPortal)) + { + if (i == WORLD_KRABS) { - zEntEvent(sTaxiConfirmGrp, eEventUIFocusOn); + zUI_PortalToKrabs(j); } - return; + zSceneSwitch(&sWorld[i].task[j].portal, 1); + zGameStateSwitchEvent(eEventDispatcher_SetGameState_SceneSwitch); + + gPendingPlayer = sWorldInfo[i].taskInfo[j].player; + } + else if (select->uiButton & XPAD_BUTTON_X && !xEntIsVisible(sConfirmation) && + sWorld[i].task[j].portal.passet && + (sWorld[i].task[j].counter->count > 0 || + globals.player.g.CheatAlwaysPortal)) + { + zEntEvent(sTaxiConfirmGrp, eEventUIFocusOn); } - } - xprintf(_stringBase0_54 + 536); - return; + return; + } } + + xprintf("All tasks had NULL UIs"); + return; } - xprintf(_stringBase0_54 + 559); + xprintf("All worlds had NULL UIs"); } -#endif void zUI_ScenePortalSave(xSerial* s) { @@ -1904,21 +1982,7 @@ void zUI_ScenePortalLoad(xSerial* s) } } -extern "C" { -static void __sinit_zUI_cpp() -{ - cKeyUIid1off = xStrHash(_stringBase0_54 + 16); - cKeyUIid2off = xStrHash(_stringBase0_54 + 29); - cKeyUIid3off = xStrHash(_stringBase0_54 + 42); - cKeyUIid4off = xStrHash(_stringBase0_54 + 55); - cKeyUIid1on = xStrHash(_stringBase0_54 + 68); - cKeyUIid2on = xStrHash(_stringBase0_54 + 80); - cKeyUIid3on = xStrHash(_stringBase0_54 + 92); - cKeyUIid4on = xStrHash(_stringBase0_54 + 104); -} -} - -void xMat3x3Scale(xMat3x3* m, const xVec3* s) +WEAK void xMat3x3Scale(xMat3x3* m, const xVec3* s) { xMat3x3ScaleC(m, s->x, s->y, s->z); } diff --git a/src/SB/Game/zUI.h b/src/SB/Game/zUI.h index b4c33d88..5d9278d4 100644 --- a/src/SB/Game/zUI.h +++ b/src/SB/Game/zUI.h @@ -50,7 +50,10 @@ struct zUIMgr : xMgr }; extern int32 bad_card_available; -extern zUIMgr gUIMgr; +// Another .comm symbol is here ("uknown_common_bss_symbol"). +// Maybe some unused variable that was still linked in? +_zUI* sSorted[768]; +zUIMgr gUIMgr; void zUI_Init(); void zUI_Init(void* ent, void* asset);