From 329ad7db6c6d4a8779d76213292fb29038e631b2 Mon Sep 17 00:00:00 2001 From: Archez Date: Thu, 25 Jan 2024 19:25:45 -0500 Subject: [PATCH] add widescreen support for skybox stars (#100) --- mm/src/code/z_kankyo.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/mm/src/code/z_kankyo.c b/mm/src/code/z_kankyo.c index 70824ba8d..e2255504a 100644 --- a/mm/src/code/z_kankyo.c +++ b/mm/src/code/z_kankyo.c @@ -3120,12 +3120,15 @@ void Environment_SetupSkyboxStars(PlayState* play) { void Environment_DrawSkyboxStar(Gfx** gfxp, f32 x, f32 y, s32 width, s32 height) { Gfx* gfx = *gfxp; - u32 xl = x * 4.0f; + // #region 2S2H [Cosmetic] Account for different aspect ratios than 4:3 + // left x coordinate turned into signed value to be used with wide texture rectangle + s32 xl = x * 4.0f; u32 yl = y * 4.0f; u32 xd = width; u32 yd = height; - gSPTextureRectangle(gfx++, xl, yl, xl + xd, yl + yd, 0, 0, 0, 0, 0); + gSPWideTextureRectangle(gfx++, xl, yl, xl + xd, yl + yd, 0, 0, 0, 0, 0); + // #endregion *gfxp = gfx; } @@ -3270,7 +3273,16 @@ void Environment_DrawSkyboxStarsImpl(PlayState* play, Gfx** gfxP) { invScale; } - if ((scale >= 1.0f) && (imgX > -1.0f) && (imgX < 1.0f) && (imgY > -1.0f) && (imgY < 1.0f)) { + // #region 2S2H [Cosmetic] Account for different aspect ratios than 4:3 + // An adjusted bounds is calculated based on the new screen width to allow more stars to be rendered + f32 adjustedXBounds = 1.0f; + if (OTRGetRectDimensionFromRightEdge(SCREEN_WIDTH) > SCREEN_WIDTH) { + adjustedXBounds = + (f32)(OTRGetRectDimensionFromRightEdge(SCREEN_WIDTH) - (SCREEN_WIDTH / 2)) / (SCREEN_WIDTH / 2); + } + + if ((scale >= 1.0f) && (imgX > -adjustedXBounds) && (imgX < adjustedXBounds) && (imgY > -1.0f) && (imgY < 1.0f)) { + // #endregion imgX = (imgX * (SCREEN_WIDTH / 2)) + (SCREEN_WIDTH / 2); imgY = (imgY * -(SCREEN_HEIGHT / 2)) + (SCREEN_HEIGHT / 2);