From 9b37cd0bedb383c8e2731eb88717267ea26bd000 Mon Sep 17 00:00:00 2001 From: shulkmaster Date: Tue, 28 Jul 2026 23:34:59 -0600 Subject: [PATCH 01/10] improve matching in `RenderMorphBallTransitionFlash` function --- src/MetroidPrime/Player/CMorphBall.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/MetroidPrime/Player/CMorphBall.cpp b/src/MetroidPrime/Player/CMorphBall.cpp index da2e69d2..526369f8 100644 --- a/src/MetroidPrime/Player/CMorphBall.cpp +++ b/src/MetroidPrime/Player/CMorphBall.cpp @@ -2050,7 +2050,9 @@ void CMorphBall::UpdateMorphBallTransitionFlash(float dt) { void CMorphBall::RenderMorphBallTransitionFlash(const CStateManager&) const { if (x19dc_morphBallTransitionFlashGen.get() != nullptr) { const uchar* color = lbl_803CEAEC + 3 * x8_ballGlowColorIdx; - const CColor modColor(color[0], color[1], color[2], 0xff); + const uchar blue = color[2]; + const uchar green = color[1]; + const CColor modColor(color[0], green, blue, 0xff); x19dc_morphBallTransitionFlashGen->SetModulationColor(modColor); x19dc_morphBallTransitionFlashGen->Render(); } From b4d58e838001eb7514fe09f56565e0548d93e206 Mon Sep 17 00:00:00 2001 From: shulkmaster Date: Wed, 29 Jul 2026 21:58:34 -0600 Subject: [PATCH 02/10] adding an inline helper to match the repeated behabior int RenderMorphBallTransitionFlash for the (red,blue,green) repeted extrantion patternt that gave away a possible inline --- src/MetroidPrime/Player/CMorphBall.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/MetroidPrime/Player/CMorphBall.cpp b/src/MetroidPrime/Player/CMorphBall.cpp index 526369f8..1a409b42 100644 --- a/src/MetroidPrime/Player/CMorphBall.cpp +++ b/src/MetroidPrime/Player/CMorphBall.cpp @@ -158,6 +158,11 @@ const uchar lbl_803CEB08[0x1c] = { 0x20, 0x00, 0x9d, 0xb6, 0xd3, 0xf1, 0x00, 0xa6, 0x86, 0xd8, 0xfb, 0x98, 0x21, 0x00, }; +inline CColor GetMorphBallGlowColor(const uchar* colors, uint colorIdx) { + const uchar* color = colors + 3 * colorIdx; + return CColor(color[0], color[1], color[2], 0xff); +} + const uchar lbl_803CEB24[0x1c] = { 0xc2, 0x8f, 0x17, 0x70, 0xd4, 0xff, 0x6a, 0xff, 0x8a, 0x3d, 0x4d, 0xff, 0xc0, 0x00, 0x00, 0x00, 0xbe, 0xdc, 0xdf, 0xff, 0x00, 0xc4, 0x9e, 0xff, 0xff, 0x9a, 0x22, 0x00, @@ -2049,11 +2054,8 @@ void CMorphBall::UpdateMorphBallTransitionFlash(float dt) { void CMorphBall::RenderMorphBallTransitionFlash(const CStateManager&) const { if (x19dc_morphBallTransitionFlashGen.get() != nullptr) { - const uchar* color = lbl_803CEAEC + 3 * x8_ballGlowColorIdx; - const uchar blue = color[2]; - const uchar green = color[1]; - const CColor modColor(color[0], green, blue, 0xff); - x19dc_morphBallTransitionFlashGen->SetModulationColor(modColor); + x19dc_morphBallTransitionFlashGen->SetModulationColor( + GetMorphBallGlowColor(lbl_803CEAEC, x8_ballGlowColorIdx)); x19dc_morphBallTransitionFlashGen->Render(); } } From 35d6664d11d7af6d01a20abbeff833f3a7ede343 Mon Sep 17 00:00:00 2001 From: shulkmaster Date: Wed, 29 Jul 2026 22:03:23 -0600 Subject: [PATCH 03/10] fixing more occurences of inline helpers --- src/MetroidPrime/Player/CMorphBall.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/MetroidPrime/Player/CMorphBall.cpp b/src/MetroidPrime/Player/CMorphBall.cpp index 1a409b42..7007a28b 100644 --- a/src/MetroidPrime/Player/CMorphBall.cpp +++ b/src/MetroidPrime/Player/CMorphBall.cpp @@ -1989,23 +1989,14 @@ void CMorphBall::Render(const CStateManager& mgr, const CActorLights* lights) co x1bc8_wakeEffectGens[x1c0c_wakeEffectIdx]->Render(); } - const uchar* glowColorData = lbl_803CEAD0 + 3 * x8_ballGlowColorIdx; - const uchar glowBlue = glowColorData[2]; - const uchar glowGreen = glowColorData[1]; - x19d0_ballInnerGlowGen->SetModulationColor(CColor(glowColorData[0], glowGreen, glowBlue, 0xff)); + x19d0_ballInnerGlowGen->SetModulationColor( + GetMorphBallGlowColor(lbl_803CEAD0, x8_ballGlowColorIdx)); if (x19d0_ballInnerGlowGen->GetNumActiveChildParticles() > 0) { CParticleGen* particle = x19d0_ballInnerGlowGen->GetActiveChildParticle(0); - const uchar* transFlashColorData = lbl_803CEAEC + 3 * x8_ballGlowColorIdx; - const uchar transFlashBlue = transFlashColorData[2]; - const uchar transFlashGreen = transFlashColorData[1]; - particle->SetModulationColor( - CColor(transFlashColorData[0], transFlashGreen, transFlashBlue, 0xff)); + particle->SetModulationColor(GetMorphBallGlowColor(lbl_803CEAEC, x8_ballGlowColorIdx)); if (x19d0_ballInnerGlowGen->GetNumActiveChildParticles() > 1) { particle = x19d0_ballInnerGlowGen->GetActiveChildParticle(1); - const uchar* auxGlowColorData = lbl_803CEB08 + 3 * x8_ballGlowColorIdx; - const uchar auxGlowBlue = auxGlowColorData[2]; - const uchar auxGlowGreen = auxGlowColorData[1]; - particle->SetModulationColor(CColor(auxGlowColorData[0], auxGlowGreen, auxGlowBlue, 0xff)); + particle->SetModulationColor(GetMorphBallGlowColor(lbl_803CEB08, x8_ballGlowColorIdx)); } } From 55b2106bb0f1c0edbdb26fc8545f83bc89cdc530 Mon Sep 17 00:00:00 2001 From: shulkmaster Date: Wed, 29 Jul 2026 22:50:33 -0600 Subject: [PATCH 04/10] inlining a second helper GetActorLightsAmbientColor --- src/MetroidPrime/Player/CMorphBall.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/MetroidPrime/Player/CMorphBall.cpp b/src/MetroidPrime/Player/CMorphBall.cpp index 7007a28b..58267512 100644 --- a/src/MetroidPrime/Player/CMorphBall.cpp +++ b/src/MetroidPrime/Player/CMorphBall.cpp @@ -163,6 +163,11 @@ inline CColor GetMorphBallGlowColor(const uchar* colors, uint colorIdx) { return CColor(color[0], color[1], color[2], 0xff); } +inline CColor GetActorLightsAmbientColor(const CActorLights& lights) { + const CVector3f& ambient = lights.GetAmbientColor(); + return CColor(ambient.GetX(), ambient.GetY(), ambient.GetZ(), 1.f); +} + const uchar lbl_803CEB24[0x1c] = { 0xc2, 0x8f, 0x17, 0x70, 0xd4, 0xff, 0x6a, 0xff, 0x8a, 0x3d, 0x4d, 0xff, 0xc0, 0x00, 0x00, 0x00, 0xbe, 0xdc, 0xdf, 0xff, 0x00, 0xc4, 0x9e, 0xff, 0xff, 0x9a, 0x22, 0x00, @@ -1846,15 +1851,13 @@ void CMorphBall::PreRender(CStateManager& mgr, const CFrustumPlanes&) { } { - CColor ambientColor(lights->GetAmbientColor().GetX(), lights->GetAmbientColor().GetY(), - lights->GetAmbientColor().GetZ(), 1.f); - lights->SetAmbientColor(CColor::Lerp(ambientColor, CColor::White(), x1c34_boostLightFactor)); + lights->SetAmbientColor(CColor::Lerp(GetActorLightsAmbientColor(*lights), CColor::White(), + x1c34_boostLightFactor)); *x1c18_actorLights = *lights; const float& lightFactor = rstl::max_val(x1c38_spiderLightFactor, x1c34_boostLightFactor); - CColor spiderAmbient(lights->GetAmbientColor().GetX(), lights->GetAmbientColor().GetY(), - lights->GetAmbientColor().GetZ(), 1.f); - x1c18_actorLights->SetAmbientColor(CColor::Lerp(spiderAmbient, CColor::White(), lightFactor)); + x1c18_actorLights->SetAmbientColor( + CColor::Lerp(GetActorLightsAmbientColor(*lights), CColor::White(), lightFactor)); } if (x58_ballModel->AnimationData() != nullptr) { From 00ccf68f78d3bcdffe80d5ec9fe905f2d92ee35c Mon Sep 17 00:00:00 2001 From: shulkmaster Date: Thu, 30 Jul 2026 12:56:30 -0600 Subject: [PATCH 05/10] renaming helper funcitions --- src/MetroidPrime/Player/CMorphBall.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/MetroidPrime/Player/CMorphBall.cpp b/src/MetroidPrime/Player/CMorphBall.cpp index 58267512..38473635 100644 --- a/src/MetroidPrime/Player/CMorphBall.cpp +++ b/src/MetroidPrime/Player/CMorphBall.cpp @@ -158,12 +158,12 @@ const uchar lbl_803CEB08[0x1c] = { 0x20, 0x00, 0x9d, 0xb6, 0xd3, 0xf1, 0x00, 0xa6, 0x86, 0xd8, 0xfb, 0x98, 0x21, 0x00, }; -inline CColor GetMorphBallGlowColor(const uchar* colors, uint colorIdx) { +inline CColor GetGlowColor(const uchar* colors, uint colorIdx) { const uchar* color = colors + 3 * colorIdx; return CColor(color[0], color[1], color[2], 0xff); } -inline CColor GetActorLightsAmbientColor(const CActorLights& lights) { +inline CColor GetAmbientColor(const CActorLights& lights) { const CVector3f& ambient = lights.GetAmbientColor(); return CColor(ambient.GetX(), ambient.GetY(), ambient.GetZ(), 1.f); } @@ -1851,13 +1851,13 @@ void CMorphBall::PreRender(CStateManager& mgr, const CFrustumPlanes&) { } { - lights->SetAmbientColor(CColor::Lerp(GetActorLightsAmbientColor(*lights), CColor::White(), - x1c34_boostLightFactor)); + lights->SetAmbientColor( + CColor::Lerp(GetAmbientColor(*lights), CColor::White(), x1c34_boostLightFactor)); *x1c18_actorLights = *lights; const float& lightFactor = rstl::max_val(x1c38_spiderLightFactor, x1c34_boostLightFactor); x1c18_actorLights->SetAmbientColor( - CColor::Lerp(GetActorLightsAmbientColor(*lights), CColor::White(), lightFactor)); + CColor::Lerp(GetAmbientColor(*lights), CColor::White(), lightFactor)); } if (x58_ballModel->AnimationData() != nullptr) { @@ -1992,14 +1992,13 @@ void CMorphBall::Render(const CStateManager& mgr, const CActorLights* lights) co x1bc8_wakeEffectGens[x1c0c_wakeEffectIdx]->Render(); } - x19d0_ballInnerGlowGen->SetModulationColor( - GetMorphBallGlowColor(lbl_803CEAD0, x8_ballGlowColorIdx)); + x19d0_ballInnerGlowGen->SetModulationColor(GetGlowColor(lbl_803CEAD0, x8_ballGlowColorIdx)); if (x19d0_ballInnerGlowGen->GetNumActiveChildParticles() > 0) { CParticleGen* particle = x19d0_ballInnerGlowGen->GetActiveChildParticle(0); - particle->SetModulationColor(GetMorphBallGlowColor(lbl_803CEAEC, x8_ballGlowColorIdx)); + particle->SetModulationColor(GetGlowColor(lbl_803CEAEC, x8_ballGlowColorIdx)); if (x19d0_ballInnerGlowGen->GetNumActiveChildParticles() > 1) { particle = x19d0_ballInnerGlowGen->GetActiveChildParticle(1); - particle->SetModulationColor(GetMorphBallGlowColor(lbl_803CEB08, x8_ballGlowColorIdx)); + particle->SetModulationColor(GetGlowColor(lbl_803CEB08, x8_ballGlowColorIdx)); } } @@ -2049,7 +2048,7 @@ void CMorphBall::UpdateMorphBallTransitionFlash(float dt) { void CMorphBall::RenderMorphBallTransitionFlash(const CStateManager&) const { if (x19dc_morphBallTransitionFlashGen.get() != nullptr) { x19dc_morphBallTransitionFlashGen->SetModulationColor( - GetMorphBallGlowColor(lbl_803CEAEC, x8_ballGlowColorIdx)); + GetGlowColor(lbl_803CEAEC, x8_ballGlowColorIdx)); x19dc_morphBallTransitionFlashGen->Render(); } } From 3866f98ede1bdf0e1dcff5ceff90b666b8b3cbd3 Mon Sep 17 00:00:00 2001 From: shulkmaster Date: Thu, 30 Jul 2026 13:34:47 -0600 Subject: [PATCH 06/10] refactoring code reinterpreting byte arrays as RGB vectors --- src/MetroidPrime/Player/CMorphBall.cpp | 38 ++++++++++++++++++-------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/MetroidPrime/Player/CMorphBall.cpp b/src/MetroidPrime/Player/CMorphBall.cpp index 38473635..1b9ee15b 100644 --- a/src/MetroidPrime/Player/CMorphBall.cpp +++ b/src/MetroidPrime/Player/CMorphBall.cpp @@ -143,24 +143,38 @@ static const char* const skSamusSpiderBallGlass = static const char* const skSamusBallFrozen = skMorphBallModelTables.x140_frozenBall[0].x0_name; namespace { -const uchar lbl_803CEAD0[0x1c] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xd5, - 0x19, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, +struct SColorRgb { + uchar x0_r; + uchar x1_g; + uchar x2_b; }; -const uchar lbl_803CEAEC[0x1c] = { - 0xc2, 0x7e, 0x10, 0x66, 0xc4, 0xff, 0x60, 0xff, 0x90, 0x33, 0x33, 0xff, 0xff, 0x20, - 0x20, 0x00, 0x9d, 0xb6, 0xd3, 0xf1, 0x00, 0xa6, 0x86, 0xd8, 0xfb, 0x98, 0x21, 0x00, +/** Morph Ball glow color palette, indexed by x8_ballGlowColorIdx */ +const SColorRgb lbl_803CEAD0[9] = { + {255, 255, 255}, // White + {255, 255, 255}, // White + {255, 255, 255}, // White + {255, 255, 255}, // White + {255, 213, 25}, // Gold + {255, 255, 255}, // White + {255, 255, 255}, // White + {255, 255, 255}, // White + {255, 255, 255}, // White }; -const uchar lbl_803CEB08[0x1c] = { - 0xc2, 0x7e, 0x10, 0x66, 0xc4, 0xff, 0x6c, 0xff, 0x61, 0x33, 0x33, 0xff, 0xff, 0x20, - 0x20, 0x00, 0x9d, 0xb6, 0xd3, 0xf1, 0x00, 0xa6, 0x86, 0xd8, 0xfb, 0x98, 0x21, 0x00, +const SColorRgb lbl_803CEAEC[9] = { + {194, 126, 16}, {102, 196, 255}, {96, 255, 144}, {51, 51, 255}, {255, 32, 32}, + {0, 157, 182}, {211, 241, 0}, {166, 134, 216}, {251, 152, 33}, }; -inline CColor GetGlowColor(const uchar* colors, uint colorIdx) { - const uchar* color = colors + 3 * colorIdx; - return CColor(color[0], color[1], color[2], 0xff); +const SColorRgb lbl_803CEB08[9] = { + {194, 126, 16}, {102, 196, 255}, {108, 255, 97}, {51, 51, 255}, {255, 32, 32}, + {0, 157, 182}, {211, 241, 0}, {166, 134, 216}, {251, 152, 33}, +}; + +inline CColor GetGlowColor(const SColorRgb* palette, uint colorIdx) { + const SColorRgb& color = palette[colorIdx]; + return CColor(color.x0_r, color.x1_g, color.x2_b, 0xff); } inline CColor GetAmbientColor(const CActorLights& lights) { From ba07981b70a12fa8d13a3a73fcac99bead2a795e Mon Sep 17 00:00:00 2001 From: shulkmaster Date: Thu, 30 Jul 2026 13:39:51 -0600 Subject: [PATCH 07/10] removing cast in callers --- src/MetroidPrime/Player/CMorphBall.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/MetroidPrime/Player/CMorphBall.cpp b/src/MetroidPrime/Player/CMorphBall.cpp index 1b9ee15b..619fadec 100644 --- a/src/MetroidPrime/Player/CMorphBall.cpp +++ b/src/MetroidPrime/Player/CMorphBall.cpp @@ -163,13 +163,27 @@ const SColorRgb lbl_803CEAD0[9] = { }; const SColorRgb lbl_803CEAEC[9] = { - {194, 126, 16}, {102, 196, 255}, {96, 255, 144}, {51, 51, 255}, {255, 32, 32}, - {0, 157, 182}, {211, 241, 0}, {166, 134, 216}, {251, 152, 33}, + {194, 126, 16}, // Ochre + {102, 196, 255}, // Sky blue + {96, 255, 144}, // Mint green + {51, 51, 255}, // Blue + {255, 32, 32}, // Red + {0, 157, 182}, // Teal + {211, 241, 0}, // Lime + {166, 134, 216}, // Lavender + {251, 152, 33}, // Orange }; const SColorRgb lbl_803CEB08[9] = { - {194, 126, 16}, {102, 196, 255}, {108, 255, 97}, {51, 51, 255}, {255, 32, 32}, - {0, 157, 182}, {211, 241, 0}, {166, 134, 216}, {251, 152, 33}, + {194, 126, 16}, // Ochre + {102, 196, 255}, // Sky blue + {108, 255, 97}, // Bright green + {51, 51, 255}, // Blue + {255, 32, 32}, // Red + {0, 157, 182}, // Teal + {211, 241, 0}, // Lime + {166, 134, 216}, // Lavender + {251, 152, 33}, // Orange }; inline CColor GetGlowColor(const SColorRgb* palette, uint colorIdx) { From 2049af7cc73f20d877a00ae762ff9023f9ec3265 Mon Sep 17 00:00:00 2001 From: shulkmaster Date: Thu, 30 Jul 2026 13:51:35 -0600 Subject: [PATCH 08/10] fixing helper signature --- src/MetroidPrime/Player/CMorphBall.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/MetroidPrime/Player/CMorphBall.cpp b/src/MetroidPrime/Player/CMorphBall.cpp index 619fadec..acc3cc98 100644 --- a/src/MetroidPrime/Player/CMorphBall.cpp +++ b/src/MetroidPrime/Player/CMorphBall.cpp @@ -186,8 +186,7 @@ const SColorRgb lbl_803CEB08[9] = { {251, 152, 33}, // Orange }; -inline CColor GetGlowColor(const SColorRgb* palette, uint colorIdx) { - const SColorRgb& color = palette[colorIdx]; +inline CColor GetGlowColor(const SColorRgb& color) { return CColor(color.x0_r, color.x1_g, color.x2_b, 0xff); } @@ -2020,13 +2019,13 @@ void CMorphBall::Render(const CStateManager& mgr, const CActorLights* lights) co x1bc8_wakeEffectGens[x1c0c_wakeEffectIdx]->Render(); } - x19d0_ballInnerGlowGen->SetModulationColor(GetGlowColor(lbl_803CEAD0, x8_ballGlowColorIdx)); + x19d0_ballInnerGlowGen->SetModulationColor(GetGlowColor(lbl_803CEAD0[x8_ballGlowColorIdx])); if (x19d0_ballInnerGlowGen->GetNumActiveChildParticles() > 0) { CParticleGen* particle = x19d0_ballInnerGlowGen->GetActiveChildParticle(0); - particle->SetModulationColor(GetGlowColor(lbl_803CEAEC, x8_ballGlowColorIdx)); + particle->SetModulationColor(GetGlowColor(lbl_803CEAEC[x8_ballGlowColorIdx])); if (x19d0_ballInnerGlowGen->GetNumActiveChildParticles() > 1) { particle = x19d0_ballInnerGlowGen->GetActiveChildParticle(1); - particle->SetModulationColor(GetGlowColor(lbl_803CEB08, x8_ballGlowColorIdx)); + particle->SetModulationColor(GetGlowColor(lbl_803CEB08[x8_ballGlowColorIdx])); } } @@ -2076,7 +2075,7 @@ void CMorphBall::UpdateMorphBallTransitionFlash(float dt) { void CMorphBall::RenderMorphBallTransitionFlash(const CStateManager&) const { if (x19dc_morphBallTransitionFlashGen.get() != nullptr) { x19dc_morphBallTransitionFlashGen->SetModulationColor( - GetGlowColor(lbl_803CEAEC, x8_ballGlowColorIdx)); + GetGlowColor(lbl_803CEAEC[x8_ballGlowColorIdx])); x19dc_morphBallTransitionFlashGen->Render(); } } From cf07fbdda18da652d31889c989ea18e4670e89f1 Mon Sep 17 00:00:00 2001 From: shulkmaster Date: Sat, 1 Aug 2026 12:07:11 -0600 Subject: [PATCH 09/10] moving static color pallet tables inside the class --- include/MetroidPrime/Player/CMorphBall.hpp | 18 +++++++++ src/MetroidPrime/Player/CMorphBall.cpp | 46 +++++++++++----------- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/include/MetroidPrime/Player/CMorphBall.hpp b/include/MetroidPrime/Player/CMorphBall.hpp index c411f945..81b49757 100644 --- a/include/MetroidPrime/Player/CMorphBall.hpp +++ b/include/MetroidPrime/Player/CMorphBall.hpp @@ -170,6 +170,12 @@ class CMorphBall : public TOneStatic< CMorphBall > { void SetDamageTimer(const float time); private: + struct SColorRgb { + uchar x0_r; + uchar x1_g; + uchar x2_b; + }; + struct CSpiderBallElectricityManager { uint x0_effectIdx; uint x4_lifetime; @@ -183,6 +189,18 @@ class CMorphBall : public TOneStatic< CMorphBall > { void SelectMorphBallSounds(const CMaterialList&); void UpdateMorphBallSound(float dt); static void PointGenerator(void*, const CVector3f*, const CVector3f*, int); + static CColor GetAmbientColor(const CActorLights&); + static CColor GetBallInnerGlowColor(uint); + static CColor GetBallGlowColor(uint); + static CColor GetBallGlowColor2(uint); + + static const SColorRgb lbl_803CEAD0[9]; + static const SColorRgb lbl_803CEAEC[9]; + static const SColorRgb lbl_803CEB08[9]; + static const uchar lbl_803CEB24[0x1c]; + static const uchar lbl_803CEB40[0x1c]; + static const uchar lbl_803CEB5C[0x1c]; + static const uchar lbl_803CEB78[0x1c]; CPlayer& x0_player; int x4_loadedModelId; diff --git a/src/MetroidPrime/Player/CMorphBall.cpp b/src/MetroidPrime/Player/CMorphBall.cpp index acc3cc98..3f96c0fd 100644 --- a/src/MetroidPrime/Player/CMorphBall.cpp +++ b/src/MetroidPrime/Player/CMorphBall.cpp @@ -142,15 +142,8 @@ static const char* const skSamusSpiderBallGlass = skMorphBallModelTables.x100_spiderBallGlass[0].x0_name; static const char* const skSamusBallFrozen = skMorphBallModelTables.x140_frozenBall[0].x0_name; -namespace { -struct SColorRgb { - uchar x0_r; - uchar x1_g; - uchar x2_b; -}; - /** Morph Ball glow color palette, indexed by x8_ballGlowColorIdx */ -const SColorRgb lbl_803CEAD0[9] = { +const CMorphBall::SColorRgb CMorphBall::lbl_803CEAD0[9] = { {255, 255, 255}, // White {255, 255, 255}, // White {255, 255, 255}, // White @@ -162,7 +155,7 @@ const SColorRgb lbl_803CEAD0[9] = { {255, 255, 255}, // White }; -const SColorRgb lbl_803CEAEC[9] = { +const CMorphBall::SColorRgb CMorphBall::lbl_803CEAEC[9] = { {194, 126, 16}, // Ochre {102, 196, 255}, // Sky blue {96, 255, 144}, // Mint green @@ -174,7 +167,7 @@ const SColorRgb lbl_803CEAEC[9] = { {251, 152, 33}, // Orange }; -const SColorRgb lbl_803CEB08[9] = { +const CMorphBall::SColorRgb CMorphBall::lbl_803CEB08[9] = { {194, 126, 16}, // Ochre {102, 196, 255}, // Sky blue {108, 255, 97}, // Bright green @@ -186,35 +179,45 @@ const SColorRgb lbl_803CEB08[9] = { {251, 152, 33}, // Orange }; -inline CColor GetGlowColor(const SColorRgb& color) { +inline CColor CMorphBall::GetBallInnerGlowColor(uint idx) { + const SColorRgb& color = lbl_803CEAD0[idx]; + return CColor(color.x0_r, color.x1_g, color.x2_b, 0xff); +} + +inline CColor CMorphBall::GetBallGlowColor(uint idx) { + const SColorRgb& color = lbl_803CEAEC[idx]; return CColor(color.x0_r, color.x1_g, color.x2_b, 0xff); } -inline CColor GetAmbientColor(const CActorLights& lights) { +inline CColor CMorphBall::GetBallGlowColor2(uint idx) { + const SColorRgb& color = lbl_803CEB08[idx]; + return CColor(color.x0_r, color.x1_g, color.x2_b, 0xff); +} + +inline CColor CMorphBall::GetAmbientColor(const CActorLights& lights) { const CVector3f& ambient = lights.GetAmbientColor(); return CColor(ambient.GetX(), ambient.GetY(), ambient.GetZ(), 1.f); } -const uchar lbl_803CEB24[0x1c] = { +const uchar CMorphBall::lbl_803CEB24[0x1c] = { 0xc2, 0x8f, 0x17, 0x70, 0xd4, 0xff, 0x6a, 0xff, 0x8a, 0x3d, 0x4d, 0xff, 0xc0, 0x00, 0x00, 0x00, 0xbe, 0xdc, 0xdf, 0xff, 0x00, 0xc4, 0x9e, 0xff, 0xff, 0x9a, 0x22, 0x00, }; -const uchar lbl_803CEB40[0x1c] = { +const uchar CMorphBall::lbl_803CEB40[0x1c] = { 0xff, 0xe6, 0x00, 0xff, 0xe6, 0x00, 0xff, 0xe6, 0x00, 0xff, 0xe6, 0x00, 0xff, 0x80, 0x20, 0xff, 0xe6, 0x00, 0xff, 0xe6, 0x00, 0xff, 0xe6, 0x00, 0xff, 0xe6, 0x00, 0x00, }; -const uchar lbl_803CEB5C[0x1c] = { +const uchar CMorphBall::lbl_803CEB5C[0x1c] = { 0xff, 0xcc, 0x00, 0xff, 0xcc, 0x00, 0xff, 0xcc, 0x00, 0xff, 0xcc, 0x00, 0xff, 0xd5, 0x19, 0xff, 0xcc, 0x00, 0xff, 0xcc, 0x00, 0xff, 0xcc, 0x00, 0xff, 0xcc, 0x00, 0x00, }; -const uchar lbl_803CEB78[0x1c] = { +const uchar CMorphBall::lbl_803CEB78[0x1c] = { 0xc2, 0x7e, 0x10, 0x66, 0xc4, 0xff, 0x60, 0xff, 0x90, 0x33, 0x33, 0xff, 0xff, 0x80, 0x80, 0x00, 0x9d, 0xb6, 0xd3, 0xf1, 0x00, 0x60, 0x33, 0xff, 0xfb, 0x98, 0x21, 0x00, }; -} // namespace static rstl::reserved_vector< int, 32 > skWakeEffectMap; @@ -1571,7 +1574,6 @@ void CMorphBall::ComputeBoostBallMovement(const CFinalInput& input, const CState } } else { CVector3f translation; - if (x1e20_ballAnimIdx == 1) { CAnimPlaybackParms parms(0, -1, 1.f, true); x58_ballModel->AnimationData()->SetAnimation(parms, false); @@ -2019,13 +2021,13 @@ void CMorphBall::Render(const CStateManager& mgr, const CActorLights* lights) co x1bc8_wakeEffectGens[x1c0c_wakeEffectIdx]->Render(); } - x19d0_ballInnerGlowGen->SetModulationColor(GetGlowColor(lbl_803CEAD0[x8_ballGlowColorIdx])); + x19d0_ballInnerGlowGen->SetModulationColor(GetBallInnerGlowColor(x8_ballGlowColorIdx)); if (x19d0_ballInnerGlowGen->GetNumActiveChildParticles() > 0) { CParticleGen* particle = x19d0_ballInnerGlowGen->GetActiveChildParticle(0); - particle->SetModulationColor(GetGlowColor(lbl_803CEAEC[x8_ballGlowColorIdx])); + particle->SetModulationColor(GetBallGlowColor(x8_ballGlowColorIdx)); if (x19d0_ballInnerGlowGen->GetNumActiveChildParticles() > 1) { particle = x19d0_ballInnerGlowGen->GetActiveChildParticle(1); - particle->SetModulationColor(GetGlowColor(lbl_803CEB08[x8_ballGlowColorIdx])); + particle->SetModulationColor(GetBallGlowColor2(x8_ballGlowColorIdx)); } } @@ -2075,7 +2077,7 @@ void CMorphBall::UpdateMorphBallTransitionFlash(float dt) { void CMorphBall::RenderMorphBallTransitionFlash(const CStateManager&) const { if (x19dc_morphBallTransitionFlashGen.get() != nullptr) { x19dc_morphBallTransitionFlashGen->SetModulationColor( - GetGlowColor(lbl_803CEAEC[x8_ballGlowColorIdx])); + GetBallGlowColor(x8_ballGlowColorIdx)); x19dc_morphBallTransitionFlashGen->Render(); } } From b941c2b95c90bb3743b78a11e89221c978c32ad8 Mon Sep 17 00:00:00 2001 From: shulkmaster Date: Sat, 1 Aug 2026 12:25:05 -0600 Subject: [PATCH 10/10] renaming colour pallets & method names after retro conventions --- include/MetroidPrime/Player/CMorphBall.hpp | 10 +++++----- src/MetroidPrime/Player/CMorphBall.cpp | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/MetroidPrime/Player/CMorphBall.hpp b/include/MetroidPrime/Player/CMorphBall.hpp index 81b49757..2faa90a6 100644 --- a/include/MetroidPrime/Player/CMorphBall.hpp +++ b/include/MetroidPrime/Player/CMorphBall.hpp @@ -191,12 +191,12 @@ class CMorphBall : public TOneStatic< CMorphBall > { static void PointGenerator(void*, const CVector3f*, const CVector3f*, int); static CColor GetAmbientColor(const CActorLights&); static CColor GetBallInnerGlowColor(uint); - static CColor GetBallGlowColor(uint); - static CColor GetBallGlowColor2(uint); + static CColor GetBallHullGlowColor(uint); + static CColor GetBallBoostedHullGlowColor(uint); - static const SColorRgb lbl_803CEAD0[9]; - static const SColorRgb lbl_803CEAEC[9]; - static const SColorRgb lbl_803CEB08[9]; + static const SColorRgb skBallInnerGlowColors[9]; + static const SColorRgb skBallHullGlowColors[9]; + static const SColorRgb skBallBoostedHullGlowColors[9]; static const uchar lbl_803CEB24[0x1c]; static const uchar lbl_803CEB40[0x1c]; static const uchar lbl_803CEB5C[0x1c]; diff --git a/src/MetroidPrime/Player/CMorphBall.cpp b/src/MetroidPrime/Player/CMorphBall.cpp index 3f96c0fd..a2776fcc 100644 --- a/src/MetroidPrime/Player/CMorphBall.cpp +++ b/src/MetroidPrime/Player/CMorphBall.cpp @@ -143,7 +143,7 @@ static const char* const skSamusSpiderBallGlass = static const char* const skSamusBallFrozen = skMorphBallModelTables.x140_frozenBall[0].x0_name; /** Morph Ball glow color palette, indexed by x8_ballGlowColorIdx */ -const CMorphBall::SColorRgb CMorphBall::lbl_803CEAD0[9] = { +const CMorphBall::SColorRgb CMorphBall::skBallInnerGlowColors[9] = { {255, 255, 255}, // White {255, 255, 255}, // White {255, 255, 255}, // White @@ -155,7 +155,7 @@ const CMorphBall::SColorRgb CMorphBall::lbl_803CEAD0[9] = { {255, 255, 255}, // White }; -const CMorphBall::SColorRgb CMorphBall::lbl_803CEAEC[9] = { +const CMorphBall::SColorRgb CMorphBall::skBallHullGlowColors[9] = { {194, 126, 16}, // Ochre {102, 196, 255}, // Sky blue {96, 255, 144}, // Mint green @@ -167,7 +167,7 @@ const CMorphBall::SColorRgb CMorphBall::lbl_803CEAEC[9] = { {251, 152, 33}, // Orange }; -const CMorphBall::SColorRgb CMorphBall::lbl_803CEB08[9] = { +const CMorphBall::SColorRgb CMorphBall::skBallBoostedHullGlowColors[9] = { {194, 126, 16}, // Ochre {102, 196, 255}, // Sky blue {108, 255, 97}, // Bright green @@ -180,17 +180,17 @@ const CMorphBall::SColorRgb CMorphBall::lbl_803CEB08[9] = { }; inline CColor CMorphBall::GetBallInnerGlowColor(uint idx) { - const SColorRgb& color = lbl_803CEAD0[idx]; + const SColorRgb& color = skBallInnerGlowColors[idx]; return CColor(color.x0_r, color.x1_g, color.x2_b, 0xff); } -inline CColor CMorphBall::GetBallGlowColor(uint idx) { - const SColorRgb& color = lbl_803CEAEC[idx]; +inline CColor CMorphBall::GetBallHullGlowColor(uint idx) { + const SColorRgb& color = skBallHullGlowColors[idx]; return CColor(color.x0_r, color.x1_g, color.x2_b, 0xff); } -inline CColor CMorphBall::GetBallGlowColor2(uint idx) { - const SColorRgb& color = lbl_803CEB08[idx]; +inline CColor CMorphBall::GetBallBoostedHullGlowColor(uint idx) { + const SColorRgb& color = skBallBoostedHullGlowColors[idx]; return CColor(color.x0_r, color.x1_g, color.x2_b, 0xff); } @@ -2024,10 +2024,10 @@ void CMorphBall::Render(const CStateManager& mgr, const CActorLights* lights) co x19d0_ballInnerGlowGen->SetModulationColor(GetBallInnerGlowColor(x8_ballGlowColorIdx)); if (x19d0_ballInnerGlowGen->GetNumActiveChildParticles() > 0) { CParticleGen* particle = x19d0_ballInnerGlowGen->GetActiveChildParticle(0); - particle->SetModulationColor(GetBallGlowColor(x8_ballGlowColorIdx)); + particle->SetModulationColor(GetBallHullGlowColor(x8_ballGlowColorIdx)); if (x19d0_ballInnerGlowGen->GetNumActiveChildParticles() > 1) { particle = x19d0_ballInnerGlowGen->GetActiveChildParticle(1); - particle->SetModulationColor(GetBallGlowColor2(x8_ballGlowColorIdx)); + particle->SetModulationColor(GetBallBoostedHullGlowColor(x8_ballGlowColorIdx)); } } @@ -2077,7 +2077,7 @@ void CMorphBall::UpdateMorphBallTransitionFlash(float dt) { void CMorphBall::RenderMorphBallTransitionFlash(const CStateManager&) const { if (x19dc_morphBallTransitionFlashGen.get() != nullptr) { x19dc_morphBallTransitionFlashGen->SetModulationColor( - GetBallGlowColor(x8_ballGlowColorIdx)); + GetBallHullGlowColor(x8_ballGlowColorIdx)); x19dc_morphBallTransitionFlashGen->Render(); } }