From 6725470d4f63856fd84f1493054e3e96a5a950cb Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Tue, 18 Mar 2025 16:28:05 -0500 Subject: [PATCH 1/3] xMath3: Initialize g_O3 global data --- src/SB/Core/x/xMath3.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SB/Core/x/xMath3.cpp b/src/SB/Core/x/xMath3.cpp index b95b4a568..413c8272e 100644 --- a/src/SB/Core/x/xMath3.cpp +++ b/src/SB/Core/x/xMath3.cpp @@ -7,6 +7,8 @@ #include "xMathInlines.h" // xasin, xatan2 //#include "xVec3Inlines.h" // xVec3Init, imported, realized xClimate has a declaration as well though. +xVec3 g_O3 = { 0, 0, 0 }; + void xMat4x3Copy(xMat4x3* o, const xMat4x3* m) { } From 6abdcd3de41192a1af1e0500128fc531b2ce971b Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Tue, 18 Mar 2025 16:28:42 -0500 Subject: [PATCH 2/3] zPlatform: zPlatform_Reset 100% code match --- src/SB/Game/zPlatform.cpp | 88 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/src/SB/Game/zPlatform.cpp b/src/SB/Game/zPlatform.cpp index ef0602d15..7632cbd4a 100644 --- a/src/SB/Game/zPlatform.cpp +++ b/src/SB/Game/zPlatform.cpp @@ -5,6 +5,7 @@ #include "zParEmitter.h" #include "xMath.h" +#include "xMath3.h" #include @@ -131,6 +132,93 @@ void zPlatform_BreakawayFallFX(zPlatform* ent, F32 dt) } } +void zPlatform_Reset(zPlatform* plat, xScene* sc) +{ + if (plat->subType == ZPLATFORM_SUBTYPE_BREAKAWAY) + { + plat->model = plat->am; + plat->collModel = NULL; + } + + zEntReset(plat); + + // FIXME: One of the xPlatformAssetData structs is bigger than detected by DWARF data. + // Need to eventually figure out which one it is. + xEntMotionInit(&plat->motion, plat, (xEntMotionAsset*)((char*)plat->passet + 0x3C)); + xEntMotionReset(&plat->motion, sc); + + plat->plat_flags = 0x1; + if (plat->subType == ZPLATFORM_SUBTYPE_PLATFORM) + { + plat->state = 0x3; + } + else if (plat->subType == ZPLATFORM_SUBTYPE_BREAKAWAY) + { + plat->tmr = plat->passet->ba.ba_delay; + plat->state = 0x0; + plat->pflags &= 0xF9; + plat->collis->chk = 0x0; + + xVec3Copy(&plat->frame->vel, (const xVec3*)&g_O3); + + plat->bound.mat = (xMat4x3*)plat->model->Mat; + } + else if (plat->subType == ZPLATFORM_SUBTYPE_MECH) + { + plat->state = (U16)plat->motion.mech.state; + } + else if (plat->subType == ZPLATFORM_SUBTYPE_SPRINGBOARD) + { + plat->tmr = -1.0f; + plat->ctr = 0; + } + else if (plat->subType == ZPLATFORM_SUBTYPE_PADDLE) + { + plat->tmr = 1e-9f; + plat->state = 0x2; + plat->ctr = plat->passet->paddle.startOrient; + } + else if (plat->subType == ZPLATFORM_SUBTYPE_FM) + { + for (U32 i = 0; i < 12; i++) + { + plat->fmrt->flags = 0; + + plat->fmrt->tmrs[i] = 0.0f; + plat->fmrt->ttms[i] = 0.0f; + plat->fmrt->atms[i] = 0.0f; + plat->fmrt->dtms[i] = 0.0f; + plat->fmrt->vms[i] = 0.0f; + plat->fmrt->dss[i] = 0.0f; + } + } + + if (plat->motion.type == 0x3) + { + plat->src = plat->motion.mp.src; + } + + plat->chkby &= 0xE3; + + if (plat->passet->flags & 0x4) + { + plat->chkby |= 0x18; + } + + plat->bupdate(plat, (xVec3*)&plat->model->Mat->pos); + + plat->moving = FALSE; + + if (plat->asset->modelInfoID == xStrHash("teeter_totter_pat") || + plat->asset->modelInfoID == xStrHash("teeter_totter_pat_bind")) + { + plat->plat_flags |= 0x2; + } + + plat->pauseMult = 1.0f; + plat->pauseDelta = 0.0f; +} + U32 zMechIsStartingForth(zPlatform* ent, U16 param_2) { if (ent->motion.asset->mech.type == 4) From d88fb1a9ed9cbeaf2b81d74e1af48c10c0a6d9d4 Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Tue, 18 Mar 2025 16:33:22 -0500 Subject: [PATCH 3/3] zPlatform: Document unknown platform state values --- src/SB/Game/zPlatform.cpp | 6 +++--- src/SB/Game/zPlatform.h | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/SB/Game/zPlatform.cpp b/src/SB/Game/zPlatform.cpp index 7632cbd4a..e47fdbf78 100644 --- a/src/SB/Game/zPlatform.cpp +++ b/src/SB/Game/zPlatform.cpp @@ -150,12 +150,12 @@ void zPlatform_Reset(zPlatform* plat, xScene* sc) plat->plat_flags = 0x1; if (plat->subType == ZPLATFORM_SUBTYPE_PLATFORM) { - plat->state = 0x3; + plat->state = ZPLATFORM_STATE_UNK1; } else if (plat->subType == ZPLATFORM_SUBTYPE_BREAKAWAY) { plat->tmr = plat->passet->ba.ba_delay; - plat->state = 0x0; + plat->state = ZPLATFORM_STATE_UNK2; plat->pflags &= 0xF9; plat->collis->chk = 0x0; @@ -175,7 +175,7 @@ void zPlatform_Reset(zPlatform* plat, xScene* sc) else if (plat->subType == ZPLATFORM_SUBTYPE_PADDLE) { plat->tmr = 1e-9f; - plat->state = 0x2; + plat->state = ZPLATFORM_STATE_UNK3; plat->ctr = plat->passet->paddle.startOrient; } else if (plat->subType == ZPLATFORM_SUBTYPE_FM) diff --git a/src/SB/Game/zPlatform.h b/src/SB/Game/zPlatform.h index 9a0a6db93..ac505c8db 100644 --- a/src/SB/Game/zPlatform.h +++ b/src/SB/Game/zPlatform.h @@ -161,6 +161,10 @@ struct zPlatform : zEnt #define ZPLATFORM_SUBTYPE_PADDLE 12 #define ZPLATFORM_SUBTYPE_FM 13 +#define ZPLATFORM_STATE_UNK1 0x3 +#define ZPLATFORM_STATE_UNK2 0x0 +#define ZPLATFORM_STATE_UNK3 0x2 + void zPlatform_Init(void* plat, void* asset); void zPlatform_Init(zPlatform* plat, xEntAsset* asset); void zPlatform_Setup(zPlatform* plat, xScene* sc);