From 62029c436c09047d2147f0619f30397349d20460 Mon Sep 17 00:00:00 2001 From: Kiloku Date: Sun, 2 Feb 2025 10:46:10 -0300 Subject: [PATCH 1/5] Prevent getting locked down with unitialized random seed --- src/sys/sys_math.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sys/sys_math.c b/src/sys/sys_math.c index a4ff84d9..5171644f 100644 --- a/src/sys/sys_math.c +++ b/src/sys/sys_math.c @@ -19,6 +19,9 @@ void Rand_Init(void) { } f32 Rand_ZeroOne(void) { + if (sRandSeed1 == sRandSeed2 == sRandSeed3 == 0){ + Rand_Init(); + } sRandSeed1 = (sRandSeed1 * 171) % 30269; sRandSeed2 = (sRandSeed2 * 172) % 30307; sRandSeed3 = (sRandSeed3 * 170) % 30323; From 048326d78cbd2a74f39959c9d2cc91bc3cca5f32 Mon Sep 17 00:00:00 2001 From: Kiloku Date: Sun, 2 Feb 2025 15:26:01 -0300 Subject: [PATCH 2/5] Fix black background mistakenly using HUD aspect ratio --- src/engine/fox_hud.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/engine/fox_hud.c b/src/engine/fox_hud.c index f1636f3d..e8cd1c30 100644 --- a/src/engine/fox_hud.c +++ b/src/engine/fox_hud.c @@ -1498,8 +1498,8 @@ void HUD_PauseScreen_Update(void) { sPauseScreenTimer[0] = 0; case 3: - Graphics_FillRectangle(&gMasterDisp, OTRGetRectDimensionFromLeftEdgeOverride(0), 0, - OTRGetDimensionFromRightEdgeOverride(SCREEN_WIDTH), SCREEN_HEIGHT, 0, 0, 0, 255); + Graphics_FillRectangle(&gMasterDisp, OTRGetRectDimensionFromLeftEdge(0), 0, + OTRGetDimensionFromRightEdge(SCREEN_WIDTH)+1, SCREEN_HEIGHT, 0, 0, 0, 255); gFillScreenAlphaTarget = 0; @@ -1548,8 +1548,8 @@ void HUD_PauseScreen_Update(void) { break; case 4: - Graphics_FillRectangle(&gMasterDisp, OTRGetRectDimensionFromLeftEdgeOverride(0), 0, - OTRGetDimensionFromRightEdgeOverride(SCREEN_WIDTH), SCREEN_HEIGHT, 0, 0, 0, 255); + Graphics_FillRectangle(&gMasterDisp, OTRGetRectDimensionFromLeftEdge(0), 0, + OTRGetDimensionFromRightEdge(SCREEN_WIDTH)+1, SCREEN_HEIGHT, 0, 0, 0, 255); if (sPauseScreenTimer[0] < 140) { break; } @@ -1567,8 +1567,8 @@ void HUD_PauseScreen_Update(void) { } case 5: - Graphics_FillRectangle(&gMasterDisp, OTRGetRectDimensionFromLeftEdgeOverride(0), 0, - OTRGetDimensionFromRightEdgeOverride(SCREEN_WIDTH), SCREEN_HEIGHT, 0, 0, 0, 255); + Graphics_FillRectangle(&gMasterDisp, OTRGetRectDimensionFromLeftEdge(0), 0, + OTRGetDimensionFromRightEdge(SCREEN_WIDTH)+1, SCREEN_HEIGHT, 0, 0, 0, 255); for (i = 0; i < 6; i++) { if (gPrevPlanetTeamShields[i] == -1) { From b5d82c031df2c3d68c1b94a618ed79b25400f0b8 Mon Sep 17 00:00:00 2001 From: Kiloku Date: Sun, 2 Feb 2025 15:27:16 -0300 Subject: [PATCH 3/5] Use HUD aspect ratio for 'HELP!!' arrows and edge proximity arrows --- src/engine/fox_display.c | 16 ++++++++-------- src/engine/fox_hud.c | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/engine/fox_display.c b/src/engine/fox_display.c index 1e2f9908..77cff46d 100644 --- a/src/engine/fox_display.c +++ b/src/engine/fox_display.c @@ -92,10 +92,10 @@ void Display_DrawHelpAlert(void) { switch (centered) { case false: if (gTeamHelpActor->sfxSource[0] > 0.0f) { - sp78 = 20.0f * OTRGetAspectRatio() - 8; + sp78 = 20.0f * OTRGetHUDAspectRatio() - 8; sp74 = M_PI / 2; } else { - sp78 = -20.0f * OTRGetAspectRatio() + 8; + sp78 = -20.0f * OTRGetHUDAspectRatio() + 8; sp74 = -M_PI / 2; } Matrix_Push(&gGfxMatrix); @@ -120,7 +120,7 @@ void Display_DrawHelpAlert(void) { // @port: Tag the transform. FrameInterpolation_RecordOpenChild("Display_DrawHelpAlert", centered); - Matrix_Translate(gGfxMatrix, 20.0f * OTRGetAspectRatio() - 8, 0.0f, -50.0f, MTXF_APPLY); + Matrix_Translate(gGfxMatrix, 20.0f * OTRGetHUDAspectRatio() - 8, 0.0f, -50.0f, MTXF_APPLY); Matrix_RotateZ(gGfxMatrix, -M_PI / 2, MTXF_APPLY); Matrix_Scale(gGfxMatrix, 0.03f, 0.03f, 0.03f, MTXF_APPLY); Matrix_SetGfxMtx(&gMasterDisp); @@ -130,7 +130,7 @@ void Display_DrawHelpAlert(void) { // left arrow (both in simultaneous) Matrix_Push(&gGfxMatrix); - Matrix_Translate(gGfxMatrix, -20.0f * OTRGetAspectRatio() + 8, 0.0f, -50.0f, MTXF_APPLY); + Matrix_Translate(gGfxMatrix, -20.0f * OTRGetHUDAspectRatio() + 8, 0.0f, -50.0f, MTXF_APPLY); Matrix_RotateZ(gGfxMatrix, M_PI / 2, MTXF_APPLY); Matrix_Scale(gGfxMatrix, 0.03f, 0.03f, 0.03f, MTXF_APPLY); Matrix_SetGfxMtx(&gMasterDisp); @@ -147,17 +147,17 @@ void Display_DrawHelpAlert(void) { RCP_SetupDL(&gMasterDisp, SETUPDL_76_POINT); gDPSetPrimColor(gMasterDisp++, 0x00, 0x00, 255, 255, 0, 255); if (sp78 < 0.0f) { - Graphics_DisplaySmallText(OTRGetRectDimensionFromLeftEdge(38.0f), 106, 1.0f, 1.0f, "HELP!!"); + Graphics_DisplaySmallText(OTRGetRectDimensionFromLeftEdgeOverride(38.0f), 106, 1.0f, 1.0f, "HELP!!"); } else { - Graphics_DisplaySmallText(OTRGetRectDimensionFromRightEdge(248), 106, 1.0f, 1.0f, "HELP!!"); + Graphics_DisplaySmallText(OTRGetRectDimensionFromRightEdgeOverride(248), 106, 1.0f, 1.0f, "HELP!!"); } break; case true: RCP_SetupDL(&gMasterDisp, SETUPDL_76_POINT); gDPSetPrimColor(gMasterDisp++, 0x00, 0x00, 255, 255, 0, 255); - Graphics_DisplaySmallText(OTRGetRectDimensionFromLeftEdge(38.0f), 106, 1.0f, 1.0f, "HELP!!"); - Graphics_DisplaySmallText(OTRGetRectDimensionFromRightEdge(248), 106, 1.0f, 1.0f, "HELP!!"); + Graphics_DisplaySmallText(OTRGetRectDimensionFromLeftEdgeOverride(38.0f), 106, 1.0f, 1.0f, "HELP!!"); + Graphics_DisplaySmallText(OTRGetRectDimensionFromRightEdgeOverride(248), 106, 1.0f, 1.0f, "HELP!!"); break; } } diff --git a/src/engine/fox_hud.c b/src/engine/fox_hud.c index e8cd1c30..051ec0b6 100644 --- a/src/engine/fox_hud.c +++ b/src/engine/fox_hud.c @@ -2819,9 +2819,9 @@ void HUD_EdgeArrows_Draw(s32 idx, bool arg1) { f32 xPos = D_800D1EF8[idx]; if (xPos < 0.0f) { - xPos = xPos * OTRGetAspectRatio() + 1; + xPos = xPos * OTRGetHUDAspectRatio() + 1; } else if (xPos > 0.0f) { - xPos = xPos * OTRGetAspectRatio() - 1; + xPos = xPos * OTRGetHUDAspectRatio() - 1; } if (arg1) { From 41cc11d0f15f5a0bf75894244b3c07d2e55813af Mon Sep 17 00:00:00 2001 From: Kiloku Date: Sun, 2 Feb 2025 15:46:06 -0300 Subject: [PATCH 4/5] Apply HUD aspect ratio to Beta boost gauge --- src/port/mods/PortEnhancements.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/port/mods/PortEnhancements.c b/src/port/mods/PortEnhancements.c index d41b1077..3c156bec 100644 --- a/src/port/mods/PortEnhancements.c +++ b/src/port/mods/PortEnhancements.c @@ -280,9 +280,9 @@ void OnBoostGaugeDraw(IEvent* event){ RCP_SetupDL(&gMasterDisp, SETUPDL_76_POINT); gDPSetPrimColor(gMasterDisp++, 0, 0, 255, 255, 255, 255); - Lib_TextureRect_CI8(&gMasterDisp, D_1012290, D_10126B0, 48, 22, OTRGetRectDimensionFromRightEdge(SCREEN_WIDTH - x), y, 1.0f, 1.0f); - Lib_TextureRect_CI8(&gMasterDisp, D_10126F0, D_1012750, 24, 4, OTRGetRectDimensionFromRightEdge(SCREEN_WIDTH - (x - 9)), y + 3, 1.0f, 1.0f); - Lib_TextureRect_RGBA16(&gMasterDisp, sBoostGaugeArrow[step], 32, 32, OTRGetRectDimensionFromRightEdge(SCREEN_WIDTH - (x - 6)), y - 1, 0.9f, 0.9f); + Lib_TextureRect_CI8(&gMasterDisp, D_1012290, D_10126B0, 48, 22, OTRGetRectDimensionFromRightEdgeOverride(SCREEN_WIDTH - x), y, 1.0f, 1.0f); + Lib_TextureRect_CI8(&gMasterDisp, D_10126F0, D_1012750, 24, 4, OTRGetRectDimensionFromRightEdgeOverride(SCREEN_WIDTH - (x - 9)), y + 3, 1.0f, 1.0f); + Lib_TextureRect_RGBA16(&gMasterDisp, sBoostGaugeArrow[step], 32, 32, OTRGetRectDimensionFromRightEdgeOverride(SCREEN_WIDTH - (x - 6)), y - 1, 0.9f, 0.9f); } void OnBombCounterDraw(IEvent* ev){ From 1f79880fd55564d75d0d5225cd5842261abe37de Mon Sep 17 00:00:00 2001 From: Kiloku Date: Sun, 2 Feb 2025 16:44:44 -0300 Subject: [PATCH 5/5] Allow customizing cockpit glass opacity --- src/engine/fox_display.c | 3 ++- src/port/ui/ImguiUI.cpp | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/engine/fox_display.c b/src/engine/fox_display.c index 77cff46d..38135a6e 100644 --- a/src/engine/fox_display.c +++ b/src/engine/fox_display.c @@ -699,7 +699,8 @@ void Display_CockpitGlass(void) { Matrix_Scale(gGfxMatrix, D_display_800CA28C, D_display_800CA28C, D_display_800CA28C, MTXF_APPLY); Matrix_SetGfxMtx(&gMasterDisp); RCP_SetupDL_64_2(); - gDPSetPrimColor(gMasterDisp++, 0x00, 0x00, 255, 255, 255, 120); + u16 opacity = CVarGetInteger("gCockpitOpacity", 120); + gDPSetPrimColor(gMasterDisp++, 0x00, 0x00, 255, 255, 255, opacity); gSPClearGeometryMode(gMasterDisp++, G_CULL_BACK); gSPDisplayList(gMasterDisp++, D_arwing_30194E0); gSPSetGeometryMode(gMasterDisp++, G_CULL_BACK); diff --git a/src/port/ui/ImguiUI.cpp b/src/port/ui/ImguiUI.cpp index 6f67f8b6..122c446b 100644 --- a/src/port/ui/ImguiUI.cpp +++ b/src/port/ui/ImguiUI.cpp @@ -473,6 +473,8 @@ void DrawEnhancementsMenu() { .tooltip = "Character heads are displayed inside Arwings in all cutscenes", .defaultValue = true }); + UIWidgets::CVarSliderInt("Cockpit Glass Opacity: %d", "gCockpitOpacity", 0, 255, 120); + ImGui::EndMenu(); }