From c38bc017ce6c138071ecba4b48f7f8927994ae3a Mon Sep 17 00:00:00 2001 From: Kiloku Date: Thu, 2 Jan 2025 18:59:39 -0300 Subject: [PATCH 1/3] Naming shield gauge variables --- include/fox_hud.h | 6 ++++ include/variables.h | 2 +- src/engine/fox_hud.c | 82 +++++++++++++++++++++---------------------- src/engine/fox_play.c | 2 +- 4 files changed, 49 insertions(+), 43 deletions(-) diff --git a/include/fox_hud.h b/include/fox_hud.h index effc38e3..7f6d122f 100644 --- a/include/fox_hud.h +++ b/include/fox_hud.h @@ -55,4 +55,10 @@ typedef enum ActorMissileSeekMode { /* 2 */ MISSILE_SEEK_EITHER, } ActorMissileSeekMode; +typedef enum ShieldGaugeState { + /* 0 */ SHIELD_GAUGE_NEUTRAL, + /* 1 */ SHIELD_GAUGE_CHECK_UPGRADE, + /* 2 */ SHIELD_GAUGE_UPGRADING, +} ShieldGaugeState; + #endif diff --git a/include/variables.h b/include/variables.h index a5eb7724..82b902b3 100644 --- a/include/variables.h +++ b/include/variables.h @@ -159,7 +159,7 @@ extern s32 gRadarMissileAlarmTimer; extern s32 gTotalHits; // 0x80161714 gTotalGameScore extern f32 D_hud_80161720[3]; extern s32 gDisplayedHitCount; -extern s32 D_hud_80161730; +extern s32 gShieldGaugeState; extern s32 gShowBossHealth; // 0x80161734 // fox_std_lib diff --git a/src/engine/fox_hud.c b/src/engine/fox_hud.c index e510a638..fe517089 100644 --- a/src/engine/fox_hud.c +++ b/src/engine/fox_hud.c @@ -18,7 +18,7 @@ s32 D_80161718; s32 D_8016171C; f32 D_hud_80161720[3]; s32 gDisplayedHitCount; -s32 D_hud_80161730; +s32 gShieldGaugeState; s32 gShowBossHealth; s32 D_80161738[4]; s32 D_80161748[4]; @@ -37,10 +37,10 @@ s32 D_80161794; s32 D_80161798; f32 D_8016179C; f32 D_801617A0; -f32 D_801617A4; -f32 D_801617A8; -f32 D_801617AC; -s32 D_801617B0; +f32 shieldGaugeDesiredScale; +f32 shieldGaugeCurrentScale; +f32 shieldFillAmount; +s32 shieldUpgradeTimer; s32 gMedalStatus; s32 gMedalFlashTimer; s32 D_801617C0[10]; @@ -2324,68 +2324,68 @@ void HUD_IncomingMsg(void) { } } -s32 D_800D1EB4 = 255; -s32 D_800D1EB8 = 255; -s32 D_800D1EBC = 255; +s32 shieldBorderColorR = 255; +s32 shieldBorderColorG = 255; +s32 shieldBorderColorB = 255; void HUD_PlayerShieldGauge_Update(void) { f32 shields; - switch (D_hud_80161730) { - case 0: - D_801617B0 = 0; - D_8016179C = 20.0f; - D_801617A0 = 18.0f; + switch (gShieldGaugeState) { + case SHIELD_GAUGE_NEUTRAL: + shieldUpgradeTimer = 0; // The timer for the shield upgrade animation (on collecting 3 gold rings) + D_8016179C = 20.0f; //Unused + D_801617A0 = 18.0f; //Unused if (gGoldRingCount[0] >= 3) { - D_801617A4 = D_801617A8 = 1.5f; + shieldGaugeDesiredScale = shieldGaugeCurrentScale = 1.5f; } else { - D_801617A4 = D_801617A8 = 1.0f; + shieldGaugeDesiredScale = shieldGaugeCurrentScale = 1.0f; } shields = gPlayer[0].shields; - D_801617AC = shields / ((256.0f * D_801617A8) - 1.0f); + shieldFillAmount = shields / ((256.0f * shieldGaugeCurrentScale) - 1.0f); if (gGoldRingCount[0] >= 3) { - D_hud_80161730 = 2; + gShieldGaugeState = SHIELD_GAUGE_UPGRADING; } else { - D_hud_80161730 = 1; + gShieldGaugeState = SHIELD_GAUGE_CHECK_UPGRADE; } break; - case 1: + case SHIELD_GAUGE_CHECK_UPGRADE: if (gGoldRingCount[0] >= 3) { - D_801617B0 = 55; - D_hud_80161730 = 2; + shieldUpgradeTimer = 55; + gShieldGaugeState = SHIELD_GAUGE_UPGRADING; } - case 2: - D_800D1EB4 = D_800D1EB8 = D_800D1EBC = 255; - if (D_801617B0 > 0) { - if (--D_801617B0 == 0) { + case SHIELD_GAUGE_UPGRADING: //Shield Gauge State: Performing upgrade + shieldBorderColorR = shieldBorderColorG = shieldBorderColorB = 255; + if (shieldUpgradeTimer > 0) { + if (--shieldUpgradeTimer == 0) { gPlayer[0].heal += 128; } } - if (((D_801617B0 != 0) || ((D_801617A4 - D_801617A8) > 0.1f)) && ((gGameFrameCount & 2) != 0)) { - D_800D1EB4 = 0; - D_800D1EB8 = 255; - D_800D1EBC = 0; + if (((shieldUpgradeTimer != 0) || ((shieldGaugeDesiredScale - shieldGaugeCurrentScale) > 0.1f)) && ((gGameFrameCount & 2) != 0)) { + shieldBorderColorR = 0; + shieldBorderColorG = 255; + shieldBorderColorB = 0; } - if ((D_801617B0 == 0) && (gGoldRingCount[0] >= 3)) { - D_801617A4 = 1.5f; + if ((shieldUpgradeTimer == 0) && (gGoldRingCount[0] >= 3)) { + shieldGaugeDesiredScale = 1.5f; } else { - D_801617A4 = 1.0f; + shieldGaugeDesiredScale = 1.0f; } - Math_SmoothStepToF(&D_801617A8, D_801617A4, 0.02f, 1000.0f, 0.001f); + Math_SmoothStepToF(&shieldGaugeCurrentScale, shieldGaugeDesiredScale, 0.02f, 1000.0f, 0.001f); shields = gPlayer[0].shields; - if (shields > (256.0f * D_801617A8) - 1.0f) { - shields = (256.0f * D_801617A8) - 1.0f; + if (shields > (256.0f * shieldGaugeCurrentScale) - 1.0f) { + shields = (256.0f * shieldGaugeCurrentScale) - 1.0f; } - D_801617AC = shields / ((256.0f * D_801617A8) - 1.0f); + shieldFillAmount = shields / ((256.0f * shieldGaugeCurrentScale) - 1.0f); break; } } @@ -2393,13 +2393,13 @@ void HUD_PlayerShieldGauge_Update(void) { void HUD_PlayerShieldGauge_Draw(f32 x, f32 y) { RCP_SetupDL(&gMasterDisp, SETUPDL_75); gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, 255); - HUD_ShieldGaugeBars_Draw(x + 8.0f, y + 2.0f, D_801617A8, 1.0f, D_801617AC); + HUD_ShieldGaugeBars_Draw(x + 8.0f, y + 2.0f, shieldGaugeCurrentScale, 1.0f, shieldFillAmount); RCP_SetupDL(&gMasterDisp, SETUPDL_76); - gDPSetPrimColor(gMasterDisp++, 0, 0, D_800D1EB4, D_800D1EB8, D_800D1EBC, 255); + gDPSetPrimColor(gMasterDisp++, 0, 0, shieldBorderColorR, shieldBorderColorG, shieldBorderColorB, 255); HUD_ShieldGaugeEdgeLeft_Draw(x, y, 1.0f, 1.0f); - HUD_ShieldGaugeEdgeRight_Draw(x + 7.0f + (D_801617A8 * 6.0f * 8.0f), y, 1.0f, 1.0f); - HUD_ShieldGaugeFrame_Draw(x + 7.0f, y, D_801617A8 * 6.0f, 1.0f); + HUD_ShieldGaugeEdgeRight_Draw(x + 7.0f + (shieldGaugeCurrentScale * 6.0f * 8.0f), y, 1.0f, 1.0f); + HUD_ShieldGaugeFrame_Draw(x + 7.0f, y, shieldGaugeCurrentScale * 6.0f, 1.0f); } void HUD_PlayerShield_GoldRings(void) { @@ -3572,7 +3572,7 @@ void HUD_Draw(void) { s32 goldRings; bool medalStatus; - if (D_hud_80161730 == 0) { + if (gShieldGaugeState == SHIELD_GAUGE_NEUTRAL) { for (i = 0; i < 10; i++) { D_801617E8[i] = 0; D_801617C0[i] = 0; diff --git a/src/engine/fox_play.c b/src/engine/fox_play.c index ec3f2d9b..e8321981 100644 --- a/src/engine/fox_play.c +++ b/src/engine/fox_play.c @@ -4544,7 +4544,7 @@ void Player_Setup(Player* playerx) { D_hud_80161720[2] = 0.0f; gDisplayedHitCount = gHitCount; - D_hud_80161730 = 0; + gShieldGaugeState = SHIELD_GAUGE_NEUTRAL; gMissedZoSearchlight = gSavedZoSearchlightStatus; gObjectLoadIndex = gSavedObjectLoadIndex; gGroundSurface = gSavedGroundSurface; From 3b3216157d71bdd215ba9263a2e4e5f93695624a Mon Sep 17 00:00:00 2001 From: Kiloku Date: Thu, 2 Jan 2025 19:05:40 -0300 Subject: [PATCH 2/3] format --- src/engine/fox_hud.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/engine/fox_hud.c b/src/engine/fox_hud.c index fe517089..0963f2aa 100644 --- a/src/engine/fox_hud.c +++ b/src/engine/fox_hud.c @@ -2334,8 +2334,8 @@ void HUD_PlayerShieldGauge_Update(void) { switch (gShieldGaugeState) { case SHIELD_GAUGE_NEUTRAL: shieldUpgradeTimer = 0; // The timer for the shield upgrade animation (on collecting 3 gold rings) - D_8016179C = 20.0f; //Unused - D_801617A0 = 18.0f; //Unused + D_8016179C = 20.0f; // Unused + D_801617A0 = 18.0f; // Unused if (gGoldRingCount[0] >= 3) { shieldGaugeDesiredScale = shieldGaugeCurrentScale = 1.5f; @@ -2359,7 +2359,7 @@ void HUD_PlayerShieldGauge_Update(void) { gShieldGaugeState = SHIELD_GAUGE_UPGRADING; } - case SHIELD_GAUGE_UPGRADING: //Shield Gauge State: Performing upgrade + case SHIELD_GAUGE_UPGRADING: // Shield Gauge State: Performing upgrade shieldBorderColorR = shieldBorderColorG = shieldBorderColorB = 255; if (shieldUpgradeTimer > 0) { if (--shieldUpgradeTimer == 0) { @@ -2367,7 +2367,8 @@ void HUD_PlayerShieldGauge_Update(void) { } } - if (((shieldUpgradeTimer != 0) || ((shieldGaugeDesiredScale - shieldGaugeCurrentScale) > 0.1f)) && ((gGameFrameCount & 2) != 0)) { + if (((shieldUpgradeTimer != 0) || ((shieldGaugeDesiredScale - shieldGaugeCurrentScale) > 0.1f)) && + ((gGameFrameCount & 2) != 0)) { shieldBorderColorR = 0; shieldBorderColorG = 255; shieldBorderColorB = 0; From d1283ad19ce3fe06cf488e7df01a6013cb675b6b Mon Sep 17 00:00:00 2001 From: Kiloku Date: Fri, 3 Jan 2025 09:49:54 -0300 Subject: [PATCH 3/3] static variables --- src/engine/fox_hud.c | 64 ++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/engine/fox_hud.c b/src/engine/fox_hud.c index 0963f2aa..4ac63eb7 100644 --- a/src/engine/fox_hud.c +++ b/src/engine/fox_hud.c @@ -37,10 +37,10 @@ s32 D_80161794; s32 D_80161798; f32 D_8016179C; f32 D_801617A0; -f32 shieldGaugeDesiredScale; -f32 shieldGaugeCurrentScale; -f32 shieldFillAmount; -s32 shieldUpgradeTimer; +f32 sShieldGaugeDesiredScale; +f32 sShieldGaugeCurrentScale; +f32 sShieldFillAmount; +s32 sShieldUpgradeTimer; s32 gMedalStatus; s32 gMedalFlashTimer; s32 D_801617C0[10]; @@ -2324,27 +2324,27 @@ void HUD_IncomingMsg(void) { } } -s32 shieldBorderColorR = 255; -s32 shieldBorderColorG = 255; -s32 shieldBorderColorB = 255; +s32 sShieldBorderColorR = 255; +s32 sShieldBorderColorG = 255; +s32 sShieldBorderColorB = 255; void HUD_PlayerShieldGauge_Update(void) { f32 shields; switch (gShieldGaugeState) { case SHIELD_GAUGE_NEUTRAL: - shieldUpgradeTimer = 0; // The timer for the shield upgrade animation (on collecting 3 gold rings) - D_8016179C = 20.0f; // Unused - D_801617A0 = 18.0f; // Unused + sShieldUpgradeTimer = 0; // The timer for the shield upgrade animation (on collecting 3 gold rings) + D_8016179C = 20.0f; // Unused + D_801617A0 = 18.0f; // Unused if (gGoldRingCount[0] >= 3) { - shieldGaugeDesiredScale = shieldGaugeCurrentScale = 1.5f; + sShieldGaugeDesiredScale = sShieldGaugeCurrentScale = 1.5f; } else { - shieldGaugeDesiredScale = shieldGaugeCurrentScale = 1.0f; + sShieldGaugeDesiredScale = sShieldGaugeCurrentScale = 1.0f; } shields = gPlayer[0].shields; - shieldFillAmount = shields / ((256.0f * shieldGaugeCurrentScale) - 1.0f); + sShieldFillAmount = shields / ((256.0f * sShieldGaugeCurrentScale) - 1.0f); if (gGoldRingCount[0] >= 3) { gShieldGaugeState = SHIELD_GAUGE_UPGRADING; @@ -2355,38 +2355,38 @@ void HUD_PlayerShieldGauge_Update(void) { case SHIELD_GAUGE_CHECK_UPGRADE: if (gGoldRingCount[0] >= 3) { - shieldUpgradeTimer = 55; + sShieldUpgradeTimer = 55; gShieldGaugeState = SHIELD_GAUGE_UPGRADING; } case SHIELD_GAUGE_UPGRADING: // Shield Gauge State: Performing upgrade - shieldBorderColorR = shieldBorderColorG = shieldBorderColorB = 255; - if (shieldUpgradeTimer > 0) { - if (--shieldUpgradeTimer == 0) { + sShieldBorderColorR = sShieldBorderColorG = sShieldBorderColorB = 255; + if (sShieldUpgradeTimer > 0) { + if (--sShieldUpgradeTimer == 0) { gPlayer[0].heal += 128; } } - if (((shieldUpgradeTimer != 0) || ((shieldGaugeDesiredScale - shieldGaugeCurrentScale) > 0.1f)) && + if (((sShieldUpgradeTimer != 0) || ((sShieldGaugeDesiredScale - sShieldGaugeCurrentScale) > 0.1f)) && ((gGameFrameCount & 2) != 0)) { - shieldBorderColorR = 0; - shieldBorderColorG = 255; - shieldBorderColorB = 0; + sShieldBorderColorR = 0; + sShieldBorderColorG = 255; + sShieldBorderColorB = 0; } - if ((shieldUpgradeTimer == 0) && (gGoldRingCount[0] >= 3)) { - shieldGaugeDesiredScale = 1.5f; + if ((sShieldUpgradeTimer == 0) && (gGoldRingCount[0] >= 3)) { + sShieldGaugeDesiredScale = 1.5f; } else { - shieldGaugeDesiredScale = 1.0f; + sShieldGaugeDesiredScale = 1.0f; } - Math_SmoothStepToF(&shieldGaugeCurrentScale, shieldGaugeDesiredScale, 0.02f, 1000.0f, 0.001f); + Math_SmoothStepToF(&sShieldGaugeCurrentScale, sShieldGaugeDesiredScale, 0.02f, 1000.0f, 0.001f); shields = gPlayer[0].shields; - if (shields > (256.0f * shieldGaugeCurrentScale) - 1.0f) { - shields = (256.0f * shieldGaugeCurrentScale) - 1.0f; + if (shields > (256.0f * sShieldGaugeCurrentScale) - 1.0f) { + shields = (256.0f * sShieldGaugeCurrentScale) - 1.0f; } - shieldFillAmount = shields / ((256.0f * shieldGaugeCurrentScale) - 1.0f); + sShieldFillAmount = shields / ((256.0f * sShieldGaugeCurrentScale) - 1.0f); break; } } @@ -2394,13 +2394,13 @@ void HUD_PlayerShieldGauge_Update(void) { void HUD_PlayerShieldGauge_Draw(f32 x, f32 y) { RCP_SetupDL(&gMasterDisp, SETUPDL_75); gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, 255); - HUD_ShieldGaugeBars_Draw(x + 8.0f, y + 2.0f, shieldGaugeCurrentScale, 1.0f, shieldFillAmount); + HUD_ShieldGaugeBars_Draw(x + 8.0f, y + 2.0f, sShieldGaugeCurrentScale, 1.0f, sShieldFillAmount); RCP_SetupDL(&gMasterDisp, SETUPDL_76); - gDPSetPrimColor(gMasterDisp++, 0, 0, shieldBorderColorR, shieldBorderColorG, shieldBorderColorB, 255); + gDPSetPrimColor(gMasterDisp++, 0, 0, sShieldBorderColorR, sShieldBorderColorG, sShieldBorderColorB, 255); HUD_ShieldGaugeEdgeLeft_Draw(x, y, 1.0f, 1.0f); - HUD_ShieldGaugeEdgeRight_Draw(x + 7.0f + (shieldGaugeCurrentScale * 6.0f * 8.0f), y, 1.0f, 1.0f); - HUD_ShieldGaugeFrame_Draw(x + 7.0f, y, shieldGaugeCurrentScale * 6.0f, 1.0f); + HUD_ShieldGaugeEdgeRight_Draw(x + 7.0f + (sShieldGaugeCurrentScale * 6.0f * 8.0f), y, 1.0f, 1.0f); + HUD_ShieldGaugeFrame_Draw(x + 7.0f, y, sShieldGaugeCurrentScale * 6.0f, 1.0f); } void HUD_PlayerShield_GoldRings(void) {