From 276db580e83371f098f214ffcb657a7fb552e812 Mon Sep 17 00:00:00 2001 From: Archez Date: Thu, 5 Dec 2024 11:00:39 -0500 Subject: [PATCH] Fix display list offset values and unhandled opcodes (#4618) * Fix display list offset values and unhandled opcodes * fix unknown opcodes on custom chest textures --- .../ovl_Bg_Toki_Hikari/z_bg_toki_hikari.c | 3 +- soh/src/overlays/actors/ovl_En_Box/z_en_box.c | 30 +++++++++++++++++++ .../actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c | 3 +- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/soh/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.c b/soh/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.c index 574685b04..98904f138 100644 --- a/soh/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.c +++ b/soh/src/overlays/actors/ovl_Bg_Toki_Hikari/z_bg_toki_hikari.c @@ -179,7 +179,8 @@ void func_808BA2CC(BgTokiHikari* this, PlayState* play) { gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayListOffset(POLY_XLU_DISP++, object_toki_objects_DL_0009C0, 10); + // SOH [Port] Index adjust 11 -> 14 (for LUS marker and gsSPVertex) to account for our extraction size changes + gSPDisplayListOffset(POLY_XLU_DISP++, object_toki_objects_DL_0009C0, 10 + 2 + 1); Matrix_Pop(); CLOSE_DISPS(play->state.gfxCtx); } diff --git a/soh/src/overlays/actors/ovl_En_Box/z_en_box.c b/soh/src/overlays/actors/ovl_En_Box/z_en_box.c index f3c7e86ff..9a52fa615 100644 --- a/soh/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/soh/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -737,6 +737,8 @@ void EnBox_CreateExtraChestTextures() { gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, gChristmasGreenTreasureChestSideAndTopTex), }; + Gfx gNoOp[] = { gsDPNoOp() }; + Gfx* frontCmd = ResourceMgr_LoadGfxByName(gTreasureChestChestFrontDL); int frontIndex = 0; while (frontCmd->words.w0 >> 24 != G_ENDDL) { @@ -745,6 +747,20 @@ void EnBox_CreateExtraChestTextures() { gKeyTreasureChestChestFrontDL[frontIndex] = *frontCmd; gChristmasRedTreasureChestChestFrontDL[frontIndex] = *frontCmd; gChristmasGreenTreasureChestChestFrontDL[frontIndex] = *frontCmd; + + // Set the second instruction of img OTR hash opcode to noop, since we will replace it with the + // OTR filepath opcode below + if (frontCmd->words.w0 >> 24 == G_SETTIMG_OTR_HASH) { + frontIndex++; + ++frontCmd; + + gSkullTreasureChestChestFrontDL[frontIndex] = gNoOp[0]; + gGoldTreasureChestChestFrontDL[frontIndex] = gNoOp[0]; + gKeyTreasureChestChestFrontDL[frontIndex] = gNoOp[0]; + gChristmasRedTreasureChestChestFrontDL[frontIndex] = gNoOp[0]; + gChristmasGreenTreasureChestChestFrontDL[frontIndex] = gNoOp[0]; + } + frontIndex++; ++frontCmd; } @@ -783,6 +799,20 @@ void EnBox_CreateExtraChestTextures() { gKeyTreasureChestChestSideAndLidDL[sideIndex] = *sideCmd; gChristmasRedTreasureChestChestSideAndLidDL[sideIndex] = *sideCmd; gChristmasGreenTreasureChestChestSideAndLidDL[sideIndex] = *sideCmd; + + // Set the second instruction of img OTR hash opcode to noop, since we will replace it with the + // OTR filepath opcode below + if (sideCmd->words.w0 >> 24 == G_SETTIMG_OTR_HASH) { + sideIndex++; + ++sideCmd; + + gSkullTreasureChestChestSideAndLidDL[sideIndex] = gNoOp[0]; + gGoldTreasureChestChestSideAndLidDL[sideIndex] = gNoOp[0]; + gKeyTreasureChestChestSideAndLidDL[sideIndex] = gNoOp[0]; + gChristmasRedTreasureChestChestSideAndLidDL[sideIndex] = gNoOp[0]; + gChristmasGreenTreasureChestChestSideAndLidDL[sideIndex] = gNoOp[0]; + } + sideIndex++; ++sideCmd; } diff --git a/soh/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c b/soh/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c index 5a1cb54ce..6067ed361 100644 --- a/soh/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c +++ b/soh/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c @@ -108,7 +108,8 @@ void OceffWipe4_Draw(Actor* thisx, PlayState* play) { gSPDisplayList(POLY_XLU_DISP++, sMaterial2DL); gSPDisplayList(POLY_XLU_DISP++, Gfx_TwoTexScroll(play->state.gfxCtx, 0, scroll * 2, scroll * (-2), 32, 64, 1, scroll * (-1), scroll, 32, 32)); - gSPDisplayListOffset(POLY_XLU_DISP++, sMaterial2DL, 11); + // SOH [Port] Index adjust 11 -> 14 (for LUS marker and load texture) to account for our extraction size changes + gSPDisplayListOffset(POLY_XLU_DISP++, sMaterial2DL, 11 + 2 + 1); CLOSE_DISPS(play->state.gfxCtx); }