From 49d51e338c015cc8e9cf9b5aed9ad87a3985a8b9 Mon Sep 17 00:00:00 2001 From: big zam Date: Sun, 12 Apr 2026 10:07:51 +0930 Subject: [PATCH] D boss magma 100% matching (#946) * d_a_obj_plant: Add headers, functions (nodeCallBack, CheckCreateHeap, CreateInit, set_mtx, daObjPlant_Delete) * d_a_obj_plant: draw * CreateHeap in progress, Moved NodeCallBack higher * daObjPlant_c::CreateHeap 100% matching * daObjPlant_Create 100% matching * Fixed field 40A being unsigned, plant_execute() 99% matching * Fixed floating point order of ops, daObjPlant_Execute 100% matching * rename param * Fixed checkCreateHeap not returning * Marked as equivalent due to weak function ordering * Fixed nodeCallBack function order * PR Feedback: Removed nodeCallBack forward declaration, Moved all inline functions from h to cpp, Replaced magic numbers with enums * d_a_obj_plant 100% matching * d_a_obj_plant: Fixed matching for kiosk demo * Update src/d/actor/d_a_obj_plant.cpp Co-authored-by: LagoLunatic * d_boss_magma: dMagma_ballBoss_c::calc 81.99% matching * d_boss_magma: dMagma_ballBoss_c::calc 95.41% matching * d_boss_magma: dMagma_ballBoss_c::calc 98.06% matching * d_boss_magma: dMagma_ballBoss_c::calc 98.99% matching * dMagma_ballBoss_c::~dMagma_ballBoss_c() 100% matching, dMagma_ballBoss_c::calc(float, unsigned char, int) 99% * dMagma_ballBoss_c::calc(float, unsigned char, int) 100% matching * Autoformat * update() 100% matching * 100% matching * 100% matching * Fixed virtualFunc standing in for setup * dMagma_ballBoss_c::__vtable 100% matching * fixed mWaveTimer type, Add missing mTimer * d_boss_magma 100% matching * Regression fix: introduce union, fixed dMagma_ballBoss_c::calc matching * Fixed regression * pr feedback, removed union, restored vtable * pr feedback, square helpers * revert field_0x7c * revert mpathtimer * remove * Remove misleading mWaveTimer name, fix regression in d_magma * fix regression in d_magma --------- Co-authored-by: LagoLunatic --- configure.py | 2 +- include/d/d_magma.h | 11 ++++-- src/d/d_boss_magma.cpp | 77 +++++++++++++++++++++++++++++++++++++----- 3 files changed, 79 insertions(+), 11 deletions(-) diff --git a/configure.py b/configure.py index cf51ed339..64c20467a 100755 --- a/configure.py +++ b/configure.py @@ -519,7 +519,7 @@ config.libs = [ Object(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d/d_event_data.cpp"), Object(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d/d_event_manager.cpp"), Object(NonMatching, "d/d_magma.cpp"), - Object(NonMatching, "d/d_boss_magma.cpp"), + Object(Matching, "d/d_boss_magma.cpp"), Object(MatchingFor("GZLJ01", "GZLE01", "GZLP01"), "d/d_grass.cpp"), Object(NonMatching, "d/d_tree.cpp"), Object(NonMatching, "d/d_particle.cpp"), diff --git a/include/d/d_magma.h b/include/d/d_magma.h index 13e215e3d..8a201df96 100644 --- a/include/d/d_magma.h +++ b/include/d/d_magma.h @@ -11,9 +11,10 @@ public: virtual ~dMagma_ball_c() {} virtual void calc(f32, u8, int) = 0; virtual void update() = 0; - virtual void setup(f32, u8, int) = 0; + virtual void setup(f32, u8, int) = 0; void draw(); + BOOL rangeCheck(cXyz&, f32*); public: @@ -21,9 +22,9 @@ public: /* 0x10 */ f32 mScale; /* 0x14 */ f32 mBaseY; /* 0x18 */ s16 mWave; + /* 0x1A */ u8 mTimer; /* 0x1C */ Mtx mPosMtx; /* 0x4C */ Mtx mTexProjMtx; - /* 0x7C */ u8 mWaveTimer; }; class dMagma_ballPath_c : public dMagma_ball_c { @@ -33,6 +34,9 @@ public: virtual void calc(f32, u8, int); virtual void update(); virtual void setup(f32, u8, int); + +public: + /* 0x7C */ u8 mWaveTimer; }; class dMagma_ballBoss_c : public dMagma_ball_c { @@ -42,6 +46,9 @@ public: virtual void calc(f32, u8, int); virtual void update(); virtual void setup(f32, u8, int); + +public: + /* 0x7C */ s16 field_0x7C; }; class dMagma_floor_c { diff --git a/src/d/d_boss_magma.cpp b/src/d/d_boss_magma.cpp index 489af6716..4b1314697 100644 --- a/src/d/d_boss_magma.cpp +++ b/src/d/d_boss_magma.cpp @@ -5,26 +5,87 @@ #include "d/dolzel.h" // IWYU pragma: keep #include "d/d_magma.h" -#include "dolphin/types.h" +#include "d/actor/d_a_btd.h" +#include "d/d_s_play.h" +#include "d/d_procname.h" + +static btd_class* btd = NULL; /* 80076B00-80076CDC .text calc__17dMagma_ballBoss_cFfUci */ -void dMagma_ballBoss_c::calc(f32, u8, int) { - /* Nonmatching */ +void dMagma_ballBoss_c::calc(f32 param_1, u8 param_2, int param_3) { + if (btd != NULL && btd->m6E84 <= -150.0f) { + mPos.y = -200.0f; + return; + } + + if (btd != NULL) { + f32 diff = std::fabsf(btd->m6E7C - std::sqrtf(SQUARE(mPos.x) + SQUARE(mPos.z))); + + if (diff < 300.0f) { + f32 targetY = (mBaseY + (50.0f + REG0_F(5)) + 30.0f) - (diff * 0.1f); + cLib_addCalc2(&mPos.y, targetY, 0.5f, 20.0f); + cLib_addCalc2(&mScale, 1.5f, 0.2f, 0.2f); + + mWave = 0x4000; + field_0x7C = 1000; + return; + } + } + if (mWave < 0) { + setup(param_1, 0, -1); + mWave = 0; + } + mPos.y = mBaseY + (REG0_F(5) + 50.0f) * cM_ssin(mWave); + + mWave += field_0x7C; } /* 80076CDC-80076D50 .text update__17dMagma_ballBoss_cFv */ void dMagma_ballBoss_c::update() { - /* Nonmatching */ + mDoMtx_stack_c::transS(mPos.x, mPos.y, mPos.z); + mDoMtx_stack_c::scaleM(mScale, 1.0f, mScale); + + mDoMtx_copy(mDoMtx_stack_c::get(), mTexProjMtx); + mDoMtx_concat(j3dSys.getViewMtx(), mTexProjMtx, mPosMtx); } /* 80076D50-80076D9C .text b_a_sub__FPvPv */ -void b_a_sub(void*, void*) { - /* Nonmatching */ +void* b_a_sub(void* param_1, void* param_2) { + if (fopAcM_IsActor(param_1) && fopAcM_GetName(param_1) == PROC_BTD) { + return param_1; + } + return NULL; } /* 80076D9C-80076FEC .text setup__17dMagma_ballBoss_cFfUci */ -void dMagma_ballBoss_c::setup(f32, u8, int) { - /* Nonmatching */ +void dMagma_ballBoss_c::setup(f32 param_1, u8 param_2, int param_3) { + mPos.x = cM_rndFX(1300.0f); + mPos.y = 0.0f; + + f32 max_z = std::sqrtf(SQUARE(1300.0f) - SQUARE(this->mPos.x)); + mPos.z = cM_rndFX(max_z); + + mScale = REG0_F(11) + 0.5f + cM_rndF(REG0_F(12) + 0.5f); + + mBaseY = REG0_F(6) + -150.0f - 20.0f + param_1 + 90.0f; + + btd = (btd_class*)fpcEx_Search(b_a_sub, NULL); + + if (btd != NULL) { + if (btd->m6E88 == 1) { + f32 dist = std::sqrtf(SQUARE(mPos.x) + SQUARE(mPos.z)); + + f32 target_dist = REG0_F(16) + 800.0f; + + if (dist < target_dist) { + mBaseY += (REG0_F(17) + 0.05f) * (target_dist - dist); + } + } + mBaseY += btd->m6E84; + } + + field_0x7C = (cM_rndF(100.0f) + 400.0f); + mWave = (cM_rndF(8.0f) * 4096.0f); } /* 80076FEC-80077048 .text __dt__17dMagma_ballBoss_cFv */