From ed870e051d64e4668169f1c0cec063dab5372251 Mon Sep 17 00:00:00 2001 From: cadmic Date: Fri, 6 Sep 2024 19:48:17 -0700 Subject: [PATCH] [ntsc-1.2] Match more draw functions (#2145) * Match z_vr_box.c * Match TitleCard_Draw * Match z_player_lib.c? * Match Lights_Draw --- src/code/z_actor.c | 29 +++++++++++++++++------------ src/code/z_lights.c | 4 ++-- src/code/z_player_lib.c | 11 ++++++++--- src/code/z_vr_box.c | 4 +++- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/code/z_actor.c b/src/code/z_actor.c index f1ff2cfb4a..0624815ffb 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -772,19 +772,19 @@ void TitleCard_Update(PlayState* play, TitleCardContext* titleCtx) { void TitleCard_Draw(PlayState* play, TitleCardContext* titleCtx) { s32 width; s32 height; - s32 unused; - s32 titleX; s32 doubleWidth; - s32 titleY; - s32 titleSecondY; + s32 titleX1; + s32 titleX2; + s32 titleY1; + s32 titleY2; s32 textureLanguageOffset; if (titleCtx->alpha != 0) { width = titleCtx->width; height = titleCtx->height; doubleWidth = width * 2; - titleX = (titleCtx->x * 4) - (width * 2); - titleY = (titleCtx->y * 4) - (height * 2); + titleX1 = (titleCtx->x * 4) - (width * 2); + titleY1 = (titleCtx->y * 4) - (height * 2); OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 2824); @@ -797,8 +797,13 @@ void TitleCard_Draw(PlayState* play, TitleCardContext* titleCtx) { #else textureLanguageOffset = width * height * gSaveContext.language; #endif - height = (width * height > 0x1000) ? 0x1000 / width : height; - titleSecondY = titleY + (height * 4); + + if (width * height > 0x1000) { + height = 0x1000 / width; + } + + titleX2 = titleX1 + (doubleWidth * 2); + titleY2 = titleY1 + (height * 4); OVERLAY_DISP = Gfx_SetupDL_52NoCD(OVERLAY_DISP); @@ -809,8 +814,8 @@ void TitleCard_Draw(PlayState* play, TitleCardContext* titleCtx) { width, height, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSPTextureRectangle(OVERLAY_DISP++, titleX, titleY, ((doubleWidth * 2) + titleX) - 4, titleY + (height * 4) - 1, - G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + gSPTextureRectangle(OVERLAY_DISP++, titleX1, titleY1, titleX2 - 4, titleY2 - 1, G_TX_RENDERTILE, 0, 0, 1 << 10, + 1 << 10); height = titleCtx->height - height; @@ -820,8 +825,8 @@ void TitleCard_Draw(PlayState* play, TitleCardContext* titleCtx) { G_IM_SIZ_8b, width, height, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSPTextureRectangle(OVERLAY_DISP++, titleX, titleSecondY, ((doubleWidth * 2) + titleX) - 4, - titleSecondY + (height * 4) - 1, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + gSPTextureRectangle(OVERLAY_DISP++, titleX1, titleY2, titleX2 - 4, titleY2 + (height * 4) - 1, + G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); } CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 2880); diff --git a/src/code/z_lights.c b/src/code/z_lights.c index 4f4a9a9cd9..e9af22cd5c 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -61,8 +61,8 @@ void Lights_Draw(Lights* lights, GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx, "../z_lights.c", 339); - gSPNumLights(POLY_OPA_DISP++, lights->numLights); - gSPNumLights(POLY_XLU_DISP++, lights->numLights); + gSPNumLights(POLY_OPA_DISP++, (u32)lights->numLights); + gSPNumLights(POLY_XLU_DISP++, (u32)lights->numLights); light = &lights->l.l[0]; i = 0; diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 74cf589e49..d57cf2ed49 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -1813,8 +1813,6 @@ void Player_DrawPauseImpl(PlayState* play, void* gameplayKeep, void* linkObject, gSPDisplayList(WORK_DISP++, POLY_OPA_DISP); gSPDisplayList(WORK_DISP++, POLY_XLU_DISP); - { s32 pad[2]; } - gSPSegment(POLY_OPA_DISP++, 0x00, NULL); gDPPipeSync(POLY_OPA_DISP++); @@ -1826,7 +1824,14 @@ void Player_DrawPauseImpl(PlayState* play, void* gameplayKeep, void* linkObject, G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_PERSP | G_CYC_FILL | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2); - gSPLoadGeometryMode(POLY_OPA_DISP++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH); + + // Also matches if some of the previous graphics commands are moved inside this block too. Possible macro? + if (1) { + s32 pad[2]; + + gSPLoadGeometryMode(POLY_OPA_DISP++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH); + } + gDPSetScissor(POLY_OPA_DISP++, G_SC_NON_INTERLACE, 0, 0, width, height); gSPClipRatio(POLY_OPA_DISP++, FRUSTRATIO_1); diff --git a/src/code/z_vr_box.c b/src/code/z_vr_box.c index ca183ce482..d2aac8c1f3 100644 --- a/src/code/z_vr_box.c +++ b/src/code/z_vr_box.c @@ -69,10 +69,10 @@ s32 Skybox_CalculateFace256(SkyboxContext* skyboxCtx, Vtx* roomVtx, s32 roomVtxS s32 k; u16 index; s16 m; + s16 l; s16 ult; s16 uls; s16 vtxIdx; - s16 l; s32 xPoints[9 * 5]; s32 yPoints[9 * 5]; s32 zPoints[9 * 5]; @@ -304,6 +304,8 @@ s32 Skybox_CalculateFace128(SkyboxContext* skyboxCtx, Vtx* roomVtx, s32 roomVtxS break; } + if (1) {} + // Select gfx buffer skyboxCtx->gfx = &skyboxCtx->dListBuf[2 * faceNum][0];