From 3e0771e566a863ddfa9cd23717f547b1f2f42bab Mon Sep 17 00:00:00 2001 From: louist103 <35883445+louist103@users.noreply.github.com> Date: Mon, 8 Apr 2024 01:06:33 -0400 Subject: [PATCH] Fix powder keg crash by creating and using a larger texture. (#170) --- .../ovl_En_Bom/gPowderKegFuseTexLarger.i8.png | Bin 0 -> 268 bytes mm/assets/overlays/ovl_En_Bom/ovl_En_Bom.h | 3 ++ mm/assets/xml/overlays/ovl_En_Bom.xml | 3 ++ mm/src/overlays/actors/ovl_En_Bom/z_en_bom.c | 27 +++++++++++++++--- 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 mm/assets/custom/overlays/ovl_En_Bom/gPowderKegFuseTexLarger.i8.png diff --git a/mm/assets/custom/overlays/ovl_En_Bom/gPowderKegFuseTexLarger.i8.png b/mm/assets/custom/overlays/ovl_En_Bom/gPowderKegFuseTexLarger.i8.png new file mode 100644 index 0000000000000000000000000000000000000000..e0c022d5fe3f1ae876e02ffbbdce6076d79101e6 GIT binary patch literal 268 zcmeAS@N?(olHy`uVBq!ia0y~yVBi2@4kiW$2Jc+WI}8jAmpxq^LpWp^PcWGOXZ-*F dKLbf%aOybd%>DCd$WpLhJYD@<);T3K0RT$v9DM)) literal 0 HcmV?d00001 diff --git a/mm/assets/overlays/ovl_En_Bom/ovl_En_Bom.h b/mm/assets/overlays/ovl_En_Bom/ovl_En_Bom.h index 4db43c3f6..147ad2a0d 100644 --- a/mm/assets/overlays/ovl_En_Bom/ovl_En_Bom.h +++ b/mm/assets/overlays/ovl_En_Bom/ovl_En_Bom.h @@ -3,6 +3,9 @@ #include "align_asset_macro.h" +#define dgPowderKegFuseVtx "__OTR__overlays/ovl_En_Bom/gPowderKegFuseVtx" +static const ALIGN_ASSET(2) char gPowderKegFuseVtx[] = dgPowderKegFuseVtx; + #define dgPowderKegFuseTex "__OTR__overlays/ovl_En_Bom/gPowderKegFuseTex" static const ALIGN_ASSET(2) char gPowderKegFuseTex[] = dgPowderKegFuseTex; diff --git a/mm/assets/xml/overlays/ovl_En_Bom.xml b/mm/assets/xml/overlays/ovl_En_Bom.xml index 15bfa097c..bc4b7fead 100644 --- a/mm/assets/xml/overlays/ovl_En_Bom.xml +++ b/mm/assets/xml/overlays/ovl_En_Bom.xml @@ -2,6 +2,9 @@ + + + diff --git a/mm/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/mm/src/overlays/actors/ovl_En_Bom/z_en_bom.c index 3da93d361..e072c2737 100644 --- a/mm/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/mm/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -787,7 +787,12 @@ void func_808726DC(PlayState* play, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3, s32 a Math_Vec3f_Copy(arg1, &fuseSegmentPtr->pos); } -void EnBom_DrawKeg(PlayState* play, s32 arg1) { + +// 2S2H [Port] See comment in the draw function. +#define dgPowderKegFuseTexLarger "__OTR__overlays/ovl_En_Bom/gPowderKegFuseTexLarger" +static const ALIGN_ASSET(2) char gPowderKegFuseTexLarger[] = dgPowderKegFuseTexLarger; + +void EnBom_DrawKeg(PlayState* play, s32 timer) { s32 temp_s5; s32 i; PowderKegFuseSegment* fuseSegmentPtr = &sPowderKegFuseSegments[0]; @@ -800,9 +805,23 @@ void EnBom_DrawKeg(PlayState* play, s32 arg1) { Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gPowderKegFuseMaterialDL); - - temp_s5 = (arg1 / 240) + 1; + // 2S2H [Port] This was originally a static DL in the OTR file. The normal texture is too small to be rendered by Fast3D + // and causes a crash. + // This adds a custom texture in the OTR file and changes the DList to use the new size. At some point this should be + // done in the GFX patcher. + gDPPipeSync(POLY_OPA_DISP++); + gDPSetTextureLUT(POLY_OPA_DISP++, G_TT_NONE); + gSPClearGeometryMode(POLY_OPA_DISP++, G_CULL_BOTH); + gSPSetGeometryMode(POLY_OPA_DISP++, G_LIGHTING); + gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIDECALA, G_CC_MODULATEI_PRIM2); + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPTexture(POLY_OPA_DISP++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); + gDPLoadTextureBlock(POLY_OPA_DISP++, gPowderKegFuseTexLarger, G_IM_FMT_I, G_IM_SIZ_8b, 8, 8, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 1, 1, G_TX_NOLOD, G_TX_NOLOD); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 200, 200, 0, 255); + gSPVertex(POLY_OPA_DISP++, gPowderKegFuseVtx, 4, 0); + + temp_s5 = (timer / 240) + 1; fuseSegmentPtr2 = &sPowderKegFuseSegments[1]; for (i = 1; i < temp_s5; i++, fuseSegmentPtr2++) {