From 248539479d7249dae7ca002373e3d4877a9fb0f5 Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Fri, 12 Jan 2024 23:58:27 +0000 Subject: [PATCH] Fix screen size issues, letterbox, fade, etc (#30) --- mm/src/code/z_message.c | 8 ++++++-- mm/src/code/z_rcp.c | 16 ++++++++++------ mm/src/code/z_shrink_window.c | 20 ++++++++++++-------- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/mm/src/code/z_message.c b/mm/src/code/z_message.c index 7716ca9fe..dbd11816d 100644 --- a/mm/src/code/z_message.c +++ b/mm/src/code/z_message.c @@ -4170,8 +4170,12 @@ void Message_DrawSceneTitleCard(PlayState* play, Gfx** gfxP) { gDPSetEnvColor(gfx++, 140, 40, 160, 255); gDPLoadTextureBlock(gfx++, gSceneTitleCardGradientTex, G_IM_FMT_I, G_IM_SIZ_8b, 64, 1, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 6, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSPTextureRectangle(gfx++, 0, XREG(77) << 2, 320 << 2, (XREG(77) + XREG(76)) << 2, G_TX_RENDERTILE, 0, 0, 204, - 1 << 10); + // #region 2S2H [Cosmetic] Account for different aspect ratios than 4:3 for title card + // gSPTextureRectangle(gfx++, 0, XREG(77) << 2, 320 << 2, (XREG(77) + XREG(76)) << 2, G_TX_RENDERTILE, 0, 0, 204, + // 1 << 10); + f32 tileOffset = 204.0f / ((320.0f + (OTRGetDimensionFromRightEdge(0) * 2.0f)) / 320.0f); + gSPWideTextureRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0) << 2, XREG(77) << 2, OTRGetRectDimensionFromRightEdge(320) << 2, (XREG(77) + XREG(76)) << 2, G_TX_RENDERTILE, 8, 0, (u32)tileOffset - 1, 1 << 10); + // #endregion gDPPipeSync(gfx++); gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); gDPSetEnvColor(gfx++, 0, 0, 0, 255); diff --git a/mm/src/code/z_rcp.c b/mm/src/code/z_rcp.c index d94dd6c4d..d9678e979 100644 --- a/mm/src/code/z_rcp.c +++ b/mm/src/code/z_rcp.c @@ -1511,17 +1511,21 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g masterGfx = gGfxMasterDL->clearFillRect; - gDPFillRectangle(&masterGfx[0], 0, 0, gCfbWidth - 1, gCfbHeight - 1); - gDPPipeSync(&masterGfx[1]); - gSPEndDisplayList(&masterGfx[2]); + // #region 2S2H [Cosmetic] Account for different aspect ratios than 4:3 + gDPFillWideRectangle(masterGfx++, OTRGetRectDimensionFromLeftEdge(0), 0, OTRGetRectDimensionFromRightEdge(gCfbWidth - 1), gCfbHeight - 1); + gDPPipeSync(&masterGfx[2]); + gSPEndDisplayList(&masterGfx[3]); + // #endregion // General Fillrect? masterGfx = gGfxMasterDL->fillRect; - gDPFillRectangle(&masterGfx[0], 0, 0, gCfbWidth, gCfbHeight); - gDPPipeSync(&masterGfx[1]); - gSPEndDisplayList(&masterGfx[2]); + // #region 2S2H [Cosmetic] Account for different aspect ratios than 4:3 + gDPFillWideRectangle(masterGfx++, OTRGetRectDimensionFromLeftEdge(0), 0, OTRGetRectDimensionFromRightEdge(gCfbWidth), gCfbHeight); + gDPPipeSync(&masterGfx[2]); + gSPEndDisplayList(&masterGfx[3]); + // #endregion // Sync SP Segments with current CPU Segments diff --git a/mm/src/code/z_shrink_window.c b/mm/src/code/z_shrink_window.c index c4084a18c..4317adf12 100644 --- a/mm/src/code/z_shrink_window.c +++ b/mm/src/code/z_shrink_window.c @@ -85,15 +85,17 @@ void ShrinkWindow_Draw(GraphicsContext* gfxCtx) { gDPSetCycleType(gfx++, G_CYC_FILL); gDPSetRenderMode(gfx++, G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(gfx++, (GPACK_RGBA5551(0, 0, 0, 1) << 16) | GPACK_RGBA5551(0, 0, 0, 1)); - gDPFillRectangle(gfx++, 0, 0, gScreenWidth - 1, letterboxSize - 1); - gDPFillRectangle(gfx++, 0, gScreenHeight - letterboxSize, gScreenWidth - 1, gScreenHeight - 1); + // #region 2S2H [Cosmetic] Account for different aspect ratios than 4:3 + gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0), 0, OTRGetRectDimensionFromRightEdge(gScreenWidth - 1), letterboxSize - 1); + gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0), gScreenHeight - letterboxSize, OTRGetRectDimensionFromRightEdge(gScreenWidth - 1), gScreenHeight - 1); gDPPipeSync(gfx++); gDPSetCycleType(gfx++, G_CYC_1CYCLE); gDPSetRenderMode(gfx++, G_RM_XLU_SURF, G_RM_XLU_SURF2); gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, 0); - gDPFillRectangle(gfx++, 0, letterboxSize, gScreenWidth, letterboxSize + 1); - gDPFillRectangle(gfx++, 0, gScreenHeight - letterboxSize - 1, gScreenWidth, gScreenHeight - letterboxSize); + gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0), letterboxSize, OTRGetRectDimensionFromRightEdge(gScreenWidth), letterboxSize + 1); + gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0), gScreenHeight - letterboxSize - 1, OTRGetRectDimensionFromRightEdge(gScreenWidth), gScreenHeight - letterboxSize); + // #endregion gDPPipeSync(gfx++); OVERLAY_DISP = gfx++; @@ -111,16 +113,18 @@ void ShrinkWindow_Draw(GraphicsContext* gfxCtx) { gDPSetRenderMode(gfx++, G_RM_NOOP, G_RM_NOOP2); gDPSetFillColor(gfx++, (GPACK_RGBA5551(0, 0, 0, 1) << 16) | GPACK_RGBA5551(0, 0, 0, 1)); - gDPFillRectangle(gfx++, 0, 0, pillarboxSize - 1, gScreenHeight - 1); - gDPFillRectangle(gfx++, gScreenWidth - pillarboxSize, 0, gScreenWidth - 1, gScreenHeight - 1); + // #region 2S2H [Cosmetic] Account for different aspect ratios than 4:3 + gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(0), 0, OTRGetRectDimensionFromRightEdge(pillarboxSize - 1), gScreenHeight - 1); + gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(gScreenWidth - pillarboxSize), 0, OTRGetRectDimensionFromRightEdge(gScreenWidth - 1), gScreenHeight - 1); gDPPipeSync(gfx++); gDPSetCycleType(gfx++, G_CYC_1CYCLE); gDPSetRenderMode(gfx++, G_RM_XLU_SURF, G_RM_XLU_SURF2); gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, 0); - gDPFillRectangle(gfx++, pillarboxSize, 0, pillarboxSize + 2, gScreenHeight); - gDPFillRectangle(gfx++, gScreenWidth - pillarboxSize - 2, 0, gScreenWidth - pillarboxSize, gScreenHeight); + gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(pillarboxSize), 0, pillarboxSize + 2, gScreenHeight); + gDPFillWideRectangle(gfx++, OTRGetRectDimensionFromLeftEdge(gScreenWidth - pillarboxSize - 2), 0, OTRGetRectDimensionFromRightEdge(gScreenWidth - pillarboxSize), gScreenHeight); + // #endregion gDPPipeSync(gfx++); OVERLAY_DISP = gfx++;