From a6a2719766739a0f13b59b878ae19dc274a3678d Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Wed, 26 Mar 2025 16:48:54 -0500 Subject: [PATCH 1/5] zPlatform: zPlatFM_EventSetup to 93% code match --- src/SB/Game/zPlatform.cpp | 48 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/SB/Game/zPlatform.cpp b/src/SB/Game/zPlatform.cpp index d17a36d1f..654270524 100644 --- a/src/SB/Game/zPlatform.cpp +++ b/src/SB/Game/zPlatform.cpp @@ -443,6 +443,54 @@ void zPlatform_PaddleStartRotate(xEnt* entplat, S32 direction, S32 stutter) plat->tmr = time[0] + time[1] + time[2]; } +static void zPlatFM_EventSetup(zPlatform* plat, const F32* toParam, S32 idx) +{ + F32 ds, atm, ttm, dtm; + + // FIXME: Register issues from order of operations? + if (plat->fmrt->flags & (1 << idx)) + { + return; + } + + ds = toParam[0]; + atm = toParam[1]; + ttm = toParam[2]; + dtm = toParam[3]; + + if (atm <= 0.0f) + { + return; + } + + if (ttm > atm) + { + ttm = atm; + } + else if (ttm < 0.0f) + { + ttm = 0.0f; + } + + ttm = atm - ttm; + if (dtm > ttm) + { + dtm = ttm; + } + else if (dtm < 0.0f) + { + dtm = 0.0f; + } + + zPlatFMRunTime* fmrt = plat->fmrt; + fmrt->tmrs[idx] = atm; + fmrt->ttms[idx] = atm; + fmrt->atms[idx] = ttm; + fmrt->dtms[idx] = dtm; + fmrt->vms[idx] = 2.0f * ds / (atm - dtm + ttm); + fmrt->dss[idx] = ds; +} + S32 zPlatformEventCB(xBase* from, xBase* to, U32 toEvent, const F32* toParam, xBase* base3) { return 1; From ee7c7118dbbc6afc93efbcad96eafe36251b9367 Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Wed, 26 Mar 2025 16:59:03 -0500 Subject: [PATCH 2/5] zPlatform: Increase zPlatFM_EventSetup to 100% code match (ty @mattbruv) --- src/SB/Game/zPlatform.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SB/Game/zPlatform.cpp b/src/SB/Game/zPlatform.cpp index 654270524..afc875ef4 100644 --- a/src/SB/Game/zPlatform.cpp +++ b/src/SB/Game/zPlatform.cpp @@ -447,8 +447,8 @@ static void zPlatFM_EventSetup(zPlatform* plat, const F32* toParam, S32 idx) { F32 ds, atm, ttm, dtm; - // FIXME: Register issues from order of operations? - if (plat->fmrt->flags & (1 << idx)) + zPlatFMRunTime* fmrt = plat->fmrt; + if (fmrt->flags & (1 << idx)) { return; } @@ -482,13 +482,13 @@ static void zPlatFM_EventSetup(zPlatform* plat, const F32* toParam, S32 idx) dtm = 0.0f; } - zPlatFMRunTime* fmrt = plat->fmrt; fmrt->tmrs[idx] = atm; fmrt->ttms[idx] = atm; fmrt->atms[idx] = ttm; fmrt->dtms[idx] = dtm; fmrt->vms[idx] = 2.0f * ds / (atm - dtm + ttm); fmrt->dss[idx] = ds; + fmrt->flags |= (1 << idx); } S32 zPlatformEventCB(xBase* from, xBase* to, U32 toEvent, const F32* toParam, xBase* base3) From 3537cfbcf861dc2df86d32085ea4eba5c8c1e3bf Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Wed, 26 Mar 2025 17:27:29 -0500 Subject: [PATCH 3/5] xFFX: Define overload of xFFXAddEffect --- src/SB/Core/x/xFFX.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SB/Core/x/xFFX.h b/src/SB/Core/x/xFFX.h index 077c72305..17499f661 100644 --- a/src/SB/Core/x/xFFX.h +++ b/src/SB/Core/x/xFFX.h @@ -45,6 +45,7 @@ xFFX* xFFXAlloc(); void xFFXFree(xFFX* ffx); void xFFXTurnOn(xFFX* f); void xFFXTurnOff(xFFX* f); +S16 xFFXAddEffect(xEnt* ent, xFFX* f); S16 xFFXAddEffect(xEnt* ent, void (*dof)(xEnt*, xScene*, F32, void*), void* fd); U32 xFFXRemoveEffectByFData(xEnt* ent, void* fdata); void xFFXApplyOne(xFFX* ffx, xEnt* ent, xScene* sc, F32 dt); From 1cf0aef8ab5fafafc63bc7f9bb19e6a06ac013f2 Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Wed, 26 Mar 2025 17:33:45 -0500 Subject: [PATCH 4/5] zPlatform: zPlatform_Shake to 100% code match --- src/SB/Game/zPlatform.cpp | 30 ++++++++++++++++++++++++++++++ src/SB/Game/zPlatform.h | 1 + 2 files changed, 31 insertions(+) diff --git a/src/SB/Game/zPlatform.cpp b/src/SB/Game/zPlatform.cpp index afc875ef4..50a6b0820 100644 --- a/src/SB/Game/zPlatform.cpp +++ b/src/SB/Game/zPlatform.cpp @@ -269,6 +269,36 @@ void zPlatformTranslate(xEnt* xent, xVec3* dpos, xMat4x3* dmat) xEntMotionTranslate(&plat->motion, dpos, dmat); } +void zPlatform_Shake(zPlatform* plat, F32 _unused, F32 ampl, F32 freq) +{ + xFFXShakeState* ss; + xFFX* sfkt; + + ss = xFFXShakeAlloc(); + if (ss != NULL) + { + sfkt = xFFXAlloc(); + if (sfkt == NULL) + { + xFFXShakeFree(ss); + ss = NULL; + } + else + { + ss->disp.x = 0.0f; + ss->disp.y = -ampl; + ss->disp.z = 0.0f; + ss->dur = 1.0f; + ss->alpha = -7.0f / ss->dur; + ss->freq = freq; + ss->tmr = 0.0f; + sfkt->doEffect = xFFXShakeUpdateEnt; + sfkt->fdata = ss; + xFFXAddEffect(plat, sfkt); + } + } +} + void zPlatform_BreakawayFallFX(zPlatform* ent, F32 dt) { if (sEmitBreakaway != NULL) diff --git a/src/SB/Game/zPlatform.h b/src/SB/Game/zPlatform.h index d5594fa34..3be6b6f2e 100644 --- a/src/SB/Game/zPlatform.h +++ b/src/SB/Game/zPlatform.h @@ -175,6 +175,7 @@ void zPlatform_Load(zPlatform* ent, xSerial* s); void zPlatform_Reset(zPlatform* plat, xScene* sc); void zPlatform_PaddleStartRotate(class xEnt* entplat, S32 direction, S32 stutter); void zPlatform_Update(xEnt* ent, xScene* sc, float dt); +void zPlatform_Shake(zPlatform* plat, F32 _unused, F32 ampl, F32 freq); U32 zPlatform_PaddleCollide(xCollis* coll, const xVec3* hitsource, const xVec3* hitvel, U32 worldSpaceNorm); S32 zPlatformEventCB(xBase* from, xBase* to, U32 toEvent, const F32* toParam, xBase* base3); From 2db3b8887e3c44f460d45791236f61c86051674a Mon Sep 17 00:00:00 2001 From: Josh Sanchez Date: Wed, 26 Mar 2025 19:17:50 -0500 Subject: [PATCH 5/5] zPlatform: zPlatform_Tremble to 100% code match --- src/SB/Game/zPlatform.cpp | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/SB/Game/zPlatform.cpp b/src/SB/Game/zPlatform.cpp index 50a6b0820..d48680be3 100644 --- a/src/SB/Game/zPlatform.cpp +++ b/src/SB/Game/zPlatform.cpp @@ -29,6 +29,7 @@ char* str10 = "Check1"; void zPlatformTranslate(xEnt* xent, xVec3* dpos, xMat4x3* dmat); void zPlatform_Move(xEnt* entPlat, xScene* s, float dt, xEntFrame* frame); +static void zPlatform_Tremble(zPlatform* plat, F32 ampl, F32 freq, F32 dur); static void genericPlatRender(xEnt* ent) { @@ -299,6 +300,45 @@ void zPlatform_Shake(zPlatform* plat, F32 _unused, F32 ampl, F32 freq) } } +static void zPlatform_Tremble(zPlatform* plat, F32 ampl, F32 freq, F32 dur) +{ + xFFXShakeState* ss; + xFFX* sfkt; + xParEmitterCustomSettings info; + S32 i; + + ss = xFFXShakeAlloc(); + if (ss != NULL) + { + sfkt = xFFXAlloc(); + if (sfkt == NULL) + { + xFFXShakeFree(ss); + return; + } + + xVec3SMul(&ss->disp, (xVec3*)&globals.camera.mat, ampl); + ss->dur = dur; + ss->alpha = 1.0f / dur; + ss->freq = freq; + ss->tmr = 0.0f; + sfkt->doEffect = xFFXShakeUpdateEnt; + sfkt->fdata = ss; + xFFXAddEffect(plat, sfkt); + } + + if (sEmitTremble != NULL) + { + info.custom_flags = 0x100; + info.pos = *xEntGetCenter(plat); + for (i = 0; i < 25; i++) + { + // Emit a particle at every 30 frames? + xParEmitterEmitCustom(sEmitTremble, 1.0f / 30, &info); + } + } +} + void zPlatform_BreakawayFallFX(zPlatform* ent, F32 dt) { if (sEmitBreakaway != NULL)