From ec9b5839ade6b9ab5b9aa51260865ea7b894b496 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Wed, 23 Oct 2024 11:51:00 +1100 Subject: Cleanup gSPMatrix, rename `Matrix_New` -> `Matrix_Finalize`, add MATRIX_FINALIZE_AND_LOAD (#1729) * mtx-finalize * cleanup gSPMatrix --- src/code/sys_matrix.c | 2 +- src/code/z_actor.c | 32 +++++++--------- src/code/z_cheap_proc.c | 4 +- src/code/z_debug_display.c | 4 +- src/code/z_draw.c | 78 +++++++++++++++++++------------------- src/code/z_eff_footmark.c | 13 ++++--- src/code/z_en_item00.c | 8 ++-- src/code/z_fcurve_data_skelanime.c | 9 ++--- src/code/z_fireobj.c | 2 +- src/code/z_kankyo.c | 10 ++--- src/code/z_lifemeter.c | 2 +- src/code/z_lights.c | 2 +- src/code/z_map_disp.c | 4 +- src/code/z_parameter.c | 22 +++++------ src/code/z_player_lib.c | 51 +++++++++++-------------- src/code/z_room.c | 16 ++++---- src/code/z_skelanime.c | 30 ++++++++------- src/code/z_sub_s.c | 2 +- 18 files changed, 139 insertions(+), 152 deletions(-) (limited to 'src/code') diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c index 42ae4277b..4013e0860 100644 --- a/src/code/sys_matrix.c +++ b/src/code/sys_matrix.c @@ -1253,7 +1253,7 @@ Mtx* Matrix_ToMtx(Mtx* dest) { * * @remark original name: "_Matrix_to_Mtx_new" */ -Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx) { +Mtx* Matrix_Finalize(GraphicsContext* gfxCtx) { return Matrix_ToMtx(GRAPH_ALLOC(gfxCtx, sizeof(Mtx))); } diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 109d9d757..c39956269 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -134,7 +134,7 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, PlayState* play, Gfx* dList, shadowScale *= actor->shape.shadowScale; Matrix_Scale(actor->scale.x * shadowScale, 1.0f, actor->scale.z * shadowScale, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, dList); CLOSE_DISPS(play->state.gfxCtx); @@ -188,7 +188,7 @@ void ActorShadow_DrawFoot(PlayState* play, Light* light, MtxF* arg2, s32 lightNu Matrix_RotateYS(sp58, MTXMODE_APPLY); Matrix_Scale(shadowScaleX, 1.0f, shadowScaleX * shadowScaleZ, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, gFootShadowDL); CLOSE_DISPS(play->state.gfxCtx); @@ -601,7 +601,7 @@ void Attention_Draw(Attention* attention, PlayState* play) { Matrix_RotateZS(0x10000 / 4, MTXMODE_APPLY); Matrix_Push(); Matrix_Translate(reticle->radius, reticle->radius, 0.0f, MTXMODE_APPLY); - gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + MATRIX_FINALIZE_AND_LOAD(OVERLAY_DISP++, play->state.gfxCtx); gSPDisplayList(OVERLAY_DISP++, gLockOnReticleTriangleDL); Matrix_Pop(); } @@ -629,7 +629,7 @@ void Attention_Draw(Attention* attention, PlayState* play) { Matrix_Scale((iREG(27) + 35) / 1000.0f, (iREG(28) + 60) / 1000.0f, (iREG(29) + 50) / 1000.0f, MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, color->inner.r, color->inner.g, color->inner.b, 255); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gLockOnArrowDL); } @@ -3996,7 +3996,7 @@ void func_800BC620(Vec3f* pos, Vec3f* scale, u8 alpha, PlayState* play) { Matrix_Scale(scale->x, 1.0f, scale->z, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, gCircleShadowDL); CLOSE_DISPS(play->state.gfxCtx); @@ -4073,7 +4073,7 @@ void Actor_DrawDoorLock(PlayState* play, s32 frame, s32 type) { Matrix_Scale(entry->chainsScale, entry->chainsScale, entry->chainsScale, MTXMODE_APPLY); } - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, entry->chainDL); if ((i % 2) != 0) { @@ -4088,7 +4088,7 @@ void Actor_DrawDoorLock(PlayState* play, s32 frame, s32 type) { Matrix_Put(&baseMtxF); Matrix_Scale(frame * 0.1f, frame * 0.1f, frame * 0.1f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, entry->lockDL); CLOSE_DISPS(play->state.gfxCtx); @@ -4923,8 +4923,7 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[] Matrix_RotateZF(M_PIf, MTXMODE_APPLY); } - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gEffIceFragment2ModelDL); } @@ -4955,8 +4954,7 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[] Matrix_ReplaceRotation(&play->billboardMtxF); Matrix_Scale(steamScale, steamScale, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamModelDL); } @@ -5003,8 +5001,7 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[] currentMatrix->mf[3][1] = bodyPartsPos->y; currentMatrix->mf[3][2] = bodyPartsPos->z; - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); } @@ -5045,8 +5042,7 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[] currentMatrix->mf[3][1] = bodyPartsPos->y; currentMatrix->mf[3][2] = bodyPartsPos->z; - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gLightOrbModelDL); } @@ -5085,8 +5081,7 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[] currentMatrix->mf[3][1] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + bodyPartsPos->y; currentMatrix->mf[3][2] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + bodyPartsPos->z; - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gElectricSparkModelDL); @@ -5097,8 +5092,7 @@ void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f bodyPartsPos[] currentMatrix->mf[3][1] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + bodyPartsPos->y; currentMatrix->mf[3][2] = Rand_CenteredFloat((f32)sREG(24) + 30.0f) + bodyPartsPos->z; - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gElectricSparkModelDL); } diff --git a/src/code/z_cheap_proc.c b/src/code/z_cheap_proc.c index 9f5e469e3..5e6afcb02 100644 --- a/src/code/z_cheap_proc.c +++ b/src/code/z_cheap_proc.c @@ -11,7 +11,7 @@ void Gfx_DrawDListOpa(PlayState* play, Gfx* dList) { gfx = POLY_OPA_DISP; gSPDisplayList(&gfx[0], gSetupDLs[SETUPDL_25]); - gSPMatrix(&gfx[1], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(&gfx[1], play->state.gfxCtx); gSPDisplayList(&gfx[2], dList); POLY_OPA_DISP = &gfx[3]; @@ -30,7 +30,7 @@ void Gfx_DrawDListXlu(PlayState* play, Gfx* dList) { gfx = POLY_XLU_DISP; gSPDisplayList(&gfx[0], gSetupDLs[SETUPDL_25]); - gSPMatrix(&gfx[1], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(&gfx[1], play->state.gfxCtx); gSPDisplayList(&gfx[2], dList); POLY_XLU_DISP = &gfx[3]; diff --git a/src/code/z_debug_display.c b/src/code/z_debug_display.c index e2ee3a4d6..c1b511aea 100644 --- a/src/code/z_debug_display.c +++ b/src/code/z_debug_display.c @@ -78,7 +78,7 @@ void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, PlayStat gDPLoadTextureBlock(POLY_XLU_DISP++, texture, G_IM_FMT_I, G_IM_SIZ_8b, 16, 16, 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); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, sDebugDisplaySpriteDL); @@ -98,7 +98,7 @@ void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* dList, PlayState* Matrix_SetTranslateRotateYXZ(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, &dispObj->rot); Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, dList); CLOSE_DISPS(play->state.gfxCtx); diff --git a/src/code/z_draw.c b/src/code/z_draw.c index 1d5b967d7..125c9b879 100644 --- a/src/code/z_draw.c +++ b/src/code/z_draw.c @@ -388,7 +388,7 @@ void GetItem_DrawBombchu(PlayState* play, s16 drawId) { Gfx_SetupDL23_Opa(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); CLOSE_DISPS(play->state.gfxCtx); @@ -401,12 +401,12 @@ void GetItem_DrawPoes(PlayState* play, s16 drawId) { Gfx_SetupDL25_Opa(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); Gfx_SetupDL25_Xlu(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[1]); gSPSegment(POLY_XLU_DISP++, 0x08, @@ -416,7 +416,7 @@ void GetItem_DrawPoes(PlayState* play, s16 drawId) { Matrix_Push(); Matrix_ReplaceRotation(&play->billboardMtxF); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[3]); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[2]); @@ -432,12 +432,12 @@ void GetItem_DrawFairyBottle(PlayState* play, s16 drawId) { Gfx_SetupDL25_Opa(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); Gfx_SetupDL25_Xlu(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[1]); gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, play->state.frames * 0, play->state.frames * 0, 32, @@ -446,7 +446,7 @@ void GetItem_DrawFairyBottle(PlayState* play, s16 drawId) { Matrix_Push(); Matrix_ReplaceRotation(&play->billboardMtxF); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[2]); Matrix_Pop(); @@ -461,7 +461,7 @@ void GetItem_DrawSkullToken(PlayState* play, s16 drawId) { Gfx_SetupDL25_Opa(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); Gfx_SetupDL25_Xlu(play->state.gfxCtx); @@ -469,7 +469,7 @@ void GetItem_DrawSkullToken(PlayState* play, s16 drawId) { gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, play->state.frames * 0, -(play->state.frames * 5), 32, 32, 1, play->state.frames * 0, play->state.frames * 0, 32, 64)); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[1]); CLOSE_DISPS(play->state.gfxCtx); @@ -482,12 +482,12 @@ void GetItem_DrawCompass(PlayState* play, s16 drawId) { Gfx_SetupDL25_Opa(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); POLY_XLU_DISP = Gfx_SetupDL(POLY_XLU_DISP, SETUPDL_5); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[1]); CLOSE_DISPS(play->state.gfxCtx); @@ -503,7 +503,7 @@ void GetItem_DrawPotion(PlayState* play, s16 drawId) { gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, -play->state.frames, play->state.frames, 32, 32, 1, -play->state.frames, play->state.frames, 32, 32)); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[1]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[2]); @@ -511,7 +511,7 @@ void GetItem_DrawPotion(PlayState* play, s16 drawId) { Gfx_SetupDL25_Xlu(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[4]); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[5]); @@ -528,7 +528,7 @@ void GetItem_DrawGoronSword(PlayState* play, s16 drawId) { gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, play->state.frames * 1, play->state.frames * 0, 32, 32, 1, play->state.frames * 0, play->state.frames * 0, 32, 32)); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); CLOSE_DISPS(play->state.gfxCtx); @@ -544,7 +544,7 @@ void GetItem_DrawDekuNuts(PlayState* play, s16 drawId) { gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, play->state.frames * 6, play->state.frames * 6, 32, 32, 1, play->state.frames * 6, play->state.frames * 6, 32, 32)); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); CLOSE_DISPS(play->state.gfxCtx); @@ -560,7 +560,7 @@ void GetItem_DrawRecoveryHeart(PlayState* play, s16 drawId) { gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, play->state.frames * 0, -(play->state.frames * 3), 32, 32, 1, play->state.frames * 0, -(play->state.frames * 2), 32, 32)); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[0]); CLOSE_DISPS(play->state.gfxCtx); @@ -576,7 +576,7 @@ void GetItem_DrawFish(PlayState* play, s16 drawId) { gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, play->state.frames * 0, play->state.frames * 1, 32, 32, 1, play->state.frames * 0, play->state.frames * 1, 32, 32)); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[0]); CLOSE_DISPS(play->state.gfxCtx); @@ -592,7 +592,7 @@ void GetItem_DrawOpa0(PlayState* play, s16 drawId) { Gfx_SetupDL25_Opa(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); CLOSE_DISPS(play->state.gfxCtx); @@ -608,12 +608,12 @@ void GetItem_DrawOpa0Xlu1(PlayState* play, s16 drawId) { Gfx_SetupDL25_Opa(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); Gfx_SetupDL25_Xlu(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[1]); CLOSE_DISPS(play->state.gfxCtx); @@ -629,7 +629,7 @@ void GetItem_DrawOpa01(PlayState* play, s16 drawId) { Gfx_SetupDL25_Opa(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[1]); @@ -646,7 +646,7 @@ void GetItem_DrawXlu01(PlayState* play, s16 drawId) { Gfx_SetupDL25_Xlu(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[0]); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[1]); @@ -661,19 +661,19 @@ void GetItem_DrawSeahorse(PlayState* play, s16 drawId) { Gfx_SetupDL25_Opa(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); Gfx_SetupDL25_Xlu(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[1]); Matrix_MtxToMtxF(Lib_SegmentedToVirtual(sDrawItemTable[drawId].drawResources[3]), &mtx); Matrix_Mult(&mtx, MTXMODE_APPLY); Matrix_ReplaceRotation(&play->billboardMtxF); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[2]); CLOSE_DISPS(play->state.gfxCtx); @@ -689,17 +689,17 @@ void GetItem_DrawFairyContainer(PlayState* play, s16 drawId) { Gfx_SetupDL25_Xlu(play->state.gfxCtx); AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gGiFairyBottleTexAnim)); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[1]); Matrix_MtxToMtxF(Lib_SegmentedToVirtual(sDrawItemTable[drawId].drawResources[3]), &mtx); Matrix_Mult(&mtx, MTXMODE_APPLY); Matrix_ReplaceRotation(&play->billboardMtxF); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[2]); CLOSE_DISPS(play->state.gfxCtx); @@ -714,12 +714,12 @@ void GetItem_DrawMoonsTear(PlayState* play, s16 drawId) { Gfx_SetupDL25_Xlu(play->state.gfxCtx); AnimatedMat_Draw(play, Lib_SegmentedToVirtual(gGiMoonsTearTexAnim)); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); Matrix_ReplaceRotation(&play->billboardMtxF); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[1]); CLOSE_DISPS(play->state.gfxCtx); @@ -732,12 +732,12 @@ void GetItem_DrawMagicArrow(PlayState* play, s16 drawId) { Gfx_SetupDL25_Opa(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); Gfx_SetupDL25_Xlu(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[1]); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[2]); @@ -751,7 +751,7 @@ void GetItem_DrawUpgrades(PlayState* play, s16 drawId) { Gfx_SetupDL25_Opa(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[1]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[2]); @@ -767,13 +767,13 @@ void GetItem_DrawRupee(PlayState* play, s16 drawId) { Gfx_SetupDL25_Opa(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[1]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); Gfx_SetupDL25_Xlu(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[3]); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[2]); @@ -788,13 +788,13 @@ void GetItem_DrawSmallRupee(PlayState* play, s16 drawId) { Matrix_Scale(0.7f, 0.7f, 0.7f, MTXMODE_APPLY); Gfx_SetupDL25_Opa(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[1]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); Gfx_SetupDL25_Xlu(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[3]); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].drawResources[2]); @@ -808,7 +808,7 @@ void GetItem_DrawWallet(PlayState* play, s16 drawId) { Gfx_SetupDL25_Opa(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[1]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[2]); @@ -834,7 +834,7 @@ void GetItem_DrawRemains(PlayState* play, s16 drawId) { Gfx_SetupDL25_Opa(play->state.gfxCtx); Matrix_Scale(0.02f, 0.02f, 0.02f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].drawResources[0]); POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); diff --git a/src/code/z_eff_footmark.c b/src/code/z_eff_footmark.c index e0dc258f8..021dcd664 100644 --- a/src/code/z_eff_footmark.c +++ b/src/code/z_eff_footmark.c @@ -103,23 +103,26 @@ void EffFootmark_Update(PlayState* play) { void EffFootmark_Draw(PlayState* play) { EffFootmark* footmark; s32 i; - GraphicsContext* gfxCtx = play->state.gfxCtx; + + OPEN_DISPS(play->state.gfxCtx); Gfx_SetupDL44_Xlu(play->state.gfxCtx); - gSPDisplayList(gfxCtx->polyXlu.p++, gEffFootprintMaterialDL); + gSPDisplayList(POLY_XLU_DISP++, gEffFootprintMaterialDL); for (footmark = play->footprintInfo, i = 0; i < ARRAY_COUNT(play->footprintInfo); i++, footmark++) { if (footmark->actor != NULL) { Matrix_Put(&footmark->mf); Matrix_Scale(footmark->size * (1.0f / 0x100) * 0.7f, 1, footmark->size * (1.0f / 0x100), MTXMODE_APPLY); - gSPMatrix(gfxCtx->polyXlu.p++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); - gDPSetPrimColor(gfxCtx->polyXlu.p++, 0, 0, footmark->red, footmark->green, footmark->blue, + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, footmark->red, footmark->green, footmark->blue, footmark->alpha >> 8); - gSPDisplayList(gfxCtx->polyXlu.p++, gEffFootprintModelDL); + gSPDisplayList(POLY_XLU_DISP++, gEffFootprintModelDL); } } + + CLOSE_DISPS(gfxCtx); } diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 78f2589a0..ff7944597 100644 --- a/src/code/z_en_item00.c +++ b/src/code/z_en_item00.c @@ -797,7 +797,7 @@ void EnItem00_DrawRupee(EnItem00* this, PlayState* play) { texIndex = this->actor.params - 0x10; } - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sRupeeTextures[texIndex])); @@ -843,7 +843,7 @@ void EnItem00_DrawSprite(EnItem00* this, PlayState* play) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sItemDropTextures[texIndex])); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, gItemDropDL); @@ -859,7 +859,7 @@ void EnItem00_DrawHeartContainer(EnItem00* this, PlayState* play) { Gfx_SetupDL25_Xlu(play->state.gfxCtx); Matrix_Scale(20.0f, 20.0f, 20.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gGiHeartBorderDL); gSPDisplayList(POLY_XLU_DISP++, gGiHeartContainerDL); @@ -876,7 +876,7 @@ void EnItem00_DrawHeartPiece(EnItem00* this, PlayState* play) { Gfx_SetupDL25_Xlu(play->state.gfxCtx); func_800B8118(&this->actor, play, 0); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gHeartPieceInteriorDL); diff --git a/src/code/z_fcurve_data_skelanime.c b/src/code/z_fcurve_data_skelanime.c index 148d8b1f6..11e528ca1 100644 --- a/src/code/z_fcurve_data_skelanime.c +++ b/src/code/z_fcurve_data_skelanime.c @@ -197,8 +197,7 @@ void SkelCurve_DrawLimb(PlayState* play, s32 limbIndex, SkelCurve* skelCurve, Ov dList = limb->dList[0]; if (dList != NULL) { - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), - G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, dList); } } else if (lod == 1) { @@ -206,14 +205,12 @@ void SkelCurve_DrawLimb(PlayState* play, s32 limbIndex, SkelCurve* skelCurve, Ov dList = limb->dList[0]; if (dList != NULL) { - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), - G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, dList); } dList = limb->dList[1]; if (dList != NULL) { - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), - G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, dList); } } diff --git a/src/code/z_fireobj.c b/src/code/z_fireobj.c index c4a4630f9..fea019079 100644 --- a/src/code/z_fireobj.c +++ b/src/code/z_fireobj.c @@ -157,7 +157,7 @@ void FireObj_Draw(PlayState* play, FireObj* fire) { Matrix_SetTranslateRotateYXZ(fire->position.x, fire->position.y, fire->position.z, &vec); Matrix_Scale(fire->xScale, fire->yScale, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gEffFire1DL); CLOSE_DISPS(play->state.gfxCtx); diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 18f065a2d..ac579560d 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -1798,7 +1798,7 @@ void Environment_DrawSun(PlayState* play) { gDPSetEnvColor(POLY_OPA_DISP++, 180, (u8)(sSunColor * 255.0f), (u8)(sSunColor * 200.0f), sSunEnvAlpha); } Matrix_Scale(sSunScale, sSunScale, sSunScale, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); Gfx_SetupDL54_Opa(play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, gSunDL); } @@ -1977,7 +1977,7 @@ void Environment_DrawLensFlare(PlayState* play, EnvironmentContext* envCtx, View POLY_XLU_DISP = Gfx_SetupDL65_NoCD(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, sLensFlareColors[i].r, sLensFlareColors[i].g, sLensFlareColors[i].b, alpha * envCtx->lensFlareAlphaScale); - mtx = Matrix_NewMtx(gfxCtx); + mtx = Matrix_Finalize(gfxCtx); if (mtx != NULL) { gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetCombineLERP(POLY_XLU_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, @@ -2121,7 +2121,7 @@ void Environment_DrawRainImpl(PlayState* play, View* view, GraphicsContext* gfxC Matrix_RotateYS(yaw + (s16)(i << 5), MTXMODE_APPLY); Matrix_RotateXS(pitch + (s16)(i << 5), MTXMODE_APPLY); Matrix_Scale(0.3f, 1.0f, 0.3f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gFallingRainDropDL); } @@ -2138,7 +2138,7 @@ void Environment_DrawRainImpl(PlayState* play, View* view, GraphicsContext* gfxC (Environment_RandCentered() * 220.0f) + spE0, MTXMODE_NEW); scale = (Rand_ZeroOne() * 0.05f) + 0.05f; Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, gfxCtx); gSPDisplayList(POLY_XLU_DISP++, gEffShockwaveDL); } } @@ -2410,7 +2410,7 @@ void Environment_DrawLightning(PlayState* play, s32 unused) { Matrix_Scale(22.0f, 100.0f, 22.0f, MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 128); gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, 128); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sLightningTextures[sLightningBolts[i].textureIndex])); Gfx_SetupDL61_Xlu(play->state.gfxCtx); diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c index 67e1e278a..91f5da046 100644 --- a/src/code/z_lifemeter.c +++ b/src/code/z_lifemeter.c @@ -388,7 +388,7 @@ void LifeMeter_Draw(PlayState* play) { mtx = GRAPH_ALLOC(gfxCtx, sizeof(Mtx)); Mtx_SetTranslateScaleMtx(mtx, 1.0f - (0.32f * lifesize), 1.0f - (0.32f * lifesize), 1.0f - (0.32f * lifesize), -130.0f + offsetX, 94.5f - offsetY, 0.0f); - gSPMatrix(OVERLAY_DISP++, mtx, G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(OVERLAY_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPVertex(OVERLAY_DISP++, beatingHeartVtx, 4, 0); gSP1Quadrangle(OVERLAY_DISP++, 0, 2, 3, 1, 0); } diff --git a/src/code/z_lights.c b/src/code/z_lights.c index 1a4adeb8d..bf13917e0 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -446,7 +446,7 @@ void Lights_DrawGlow(PlayState* play) { Matrix_Translate(params->x, params->y, params->z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(gfx++, play->state.gfxCtx); gSPDisplayList(gfx++, gameplay_keep_DL_029CF0); } diff --git a/src/code/z_map_disp.c b/src/code/z_map_disp.c index 5718e1c84..e9b6c96bb 100644 --- a/src/code/z_map_disp.c +++ b/src/code/z_map_disp.c @@ -295,7 +295,7 @@ void MapDisp_Minimap_DrawActorIcon(PlayState* play, Actor* actor) { } Matrix_RotateYF(compassRot / 10.0f, MTXMODE_APPLY); Matrix_Scale(0.4f, 0.4f, 0.4f, MTXMODE_APPLY); - gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(OVERLAY_DISP++, play->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 200, 255, 0, play->interfaceCtx.minimapAlpha); gSPDisplayList(OVERLAY_DISP++, gCompassArrowDL); } else if ((actor->id == ACTOR_EN_BOX) && !Flags_GetTreasure(play, actor->params & 0x1F) && @@ -995,7 +995,7 @@ void MapDisp_Minimap_DrawRedCompassIcon(PlayState* play, s32 x, s32 z, s32 rot) } Matrix_RotateYF(rot / 10.0f, MTXMODE_APPLY); Matrix_Scale(0.4f, 0.4f, 0.4f, MTXMODE_APPLY); - gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(OVERLAY_DISP++, play->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 255, 200, 0, 0, play->interfaceCtx.minimapAlpha); gSPDisplayList(OVERLAY_DISP++, gCompassArrowDL); diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 8c672244b..bcbf27f8e 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -4386,7 +4386,7 @@ void Interface_DrawAButton(PlayState* play) { Matrix_RotateXFApply(interfaceCtx->aButtonRoll / 10000.0f); // Draw A button Shadow - gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(OVERLAY_DISP++, play->state.gfxCtx); gDPPipeSync(OVERLAY_DISP++); gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[4], 4, 0); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 0, 0, 0, aAlpha); @@ -4413,7 +4413,7 @@ void Interface_DrawAButton(PlayState* play) { Matrix_Translate(0.0f, 0.0f, sAButtonDoActionTexScales[gSaveContext.options.language] / 10.0f, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); Matrix_RotateXFApply(interfaceCtx->aButtonRoll / 10000.0f); - gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(OVERLAY_DISP++, play->state.gfxCtx); gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[8], 4, 0); // Draw Action Label @@ -4791,8 +4791,7 @@ void Interface_DrawClock(PlayState* play) { Matrix_Scale(1.0f, 1.0f, sThreeDayClockStarMinuteScale, MTXMODE_APPLY); Matrix_RotateZF(-(timeInSeconds * 0.0175f) / 10.0f, MTXMODE_APPLY); - gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(OVERLAY_DISP++, play->state.gfxCtx); gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[12], 4, 0); gDPLoadTextureBlock_4b(OVERLAY_DISP++, gThreeDayClockStarMinuteTex, G_IM_FMT_I, 16, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, @@ -4832,7 +4831,7 @@ void Interface_DrawClock(PlayState* play) { Matrix_Translate(sp1D8, temp_f14, 0.0f, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(OVERLAY_DISP++, play->state.gfxCtx); gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[16], 4, 0); OVERLAY_DISP = Gfx_DrawTexQuadIA8(OVERLAY_DISP, gThreeDayClockSunHourTex, 24, 24, 0); @@ -4849,7 +4848,7 @@ void Interface_DrawClock(PlayState* play) { Matrix_Translate(sp1D8, temp_f14, 0.0f, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(OVERLAY_DISP++, play->state.gfxCtx); gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[20], 4, 0); OVERLAY_DISP = Gfx_DrawTexQuadIA8(OVERLAY_DISP, gThreeDayClockMoonHourTex, 24, 24, 0); @@ -4870,7 +4869,7 @@ void Interface_DrawClock(PlayState* play) { Matrix_Translate(0.0f, R_THREE_DAY_CLOCK_Y_POS / 10.0f, 0.0f, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); Matrix_RotateZF(-(sp1CC - 3.15f), MTXMODE_APPLY); - gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(OVERLAY_DISP++, play->state.gfxCtx); // Draws Three-Day Clock's Hour Digit Above the Sun gDPPipeSync(OVERLAY_DISP++); @@ -4895,7 +4894,7 @@ void Interface_DrawClock(PlayState* play) { Matrix_Translate(0.0f, R_THREE_DAY_CLOCK_Y_POS / 10.0f, 0.0f, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); Matrix_RotateZF(-sp1CC, MTXMODE_APPLY); - gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(OVERLAY_DISP++, play->state.gfxCtx); // Draws Three-Day Clock's Hour Digit Above the Moon gDPPipeSync(OVERLAY_DISP++); @@ -5582,7 +5581,7 @@ void Interface_DrawPerfectLetters(PlayState* play) { Matrix_Translate(letterX, letterY, 0.0f, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(OVERLAY_DISP++, play->state.gfxCtx); gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[44 + vtxOffset], 4, 0); OVERLAY_DISP = Gfx_DrawTexQuad4b(OVERLAY_DISP, sPerfectLettersTextures[i], G_IM_FMT_I, 32, 33, 0); @@ -5596,7 +5595,7 @@ void Interface_DrawPerfectLetters(PlayState* play) { Matrix_Translate(letterX, letterY, 0.0f, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); - gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(OVERLAY_DISP++, play->state.gfxCtx); gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[76 + vtxOffset], 4, 0); OVERLAY_DISP = Gfx_DrawTexQuad4b(OVERLAY_DISP, sPerfectLettersTextures[i], G_IM_FMT_I, 32, 33, 0); @@ -6627,8 +6626,7 @@ void Interface_Draw(PlayState* play) { Matrix_Translate(0.0f, -40.0f, 0.0f, MTXMODE_NEW); Matrix_Scale(minigameCountdownScale, minigameCountdownScale, 0.0f, MTXMODE_APPLY); - gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(OVERLAY_DISP++, play->state.gfxCtx); gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[40], 4, 0); OVERLAY_DISP = Gfx_DrawTexQuadIA8(OVERLAY_DISP, sMinigameCountdownTextures[sp2CE], diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index bee458ad5..c311202b2 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -299,7 +299,7 @@ void func_80122D44(PlayState* play, struct_80122D44_arg1* arg1) { Scene_SetRenderModeXlu(play, 1, 2); gDPSetEnvColor(POLY_XLU_DISP++, temp_s3->color.r, temp_s3->color.g, temp_s3->color.b, phi_s2->alpha); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, temp_s3->dList); } @@ -2046,7 +2046,7 @@ void Player_DrawHookshotReticle(PlayState* play, Player* player, f32 hookshotDis Matrix_Translate(pos.x, pos.y, pos.z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(OVERLAY_DISP++, play->state.gfxCtx); gSPSegment(OVERLAY_DISP++, 0x06, play->objectCtx.slots[player->actor.objectSlot].segment); gSPDisplayList(OVERLAY_DISP++, gHookshotReticleDL); @@ -2182,7 +2182,7 @@ void Player_DrawZoraShield(PlayState* play, Player* player) { gfx = POLY_XLU_DISP; - gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(&gfx[0], play->state.gfxCtx); gSPDisplayList(&gfx[1], object_link_zora_DL_011760); POLY_XLU_DISP = &gfx[2]; @@ -2848,7 +2848,7 @@ void func_80126BD0(PlayState* play, Player* player, s32 arg2) { if ((arg2 != 0) && (player->stateFlags1 & PLAYER_STATE1_400000)) { OPEN_DISPS(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, object_link_zora_DL_0110A8); CLOSE_DISPS(play->state.gfxCtx); @@ -2895,7 +2895,7 @@ void func_80126BD0(PlayState* play, Player* player, s32 arg2) { Matrix_Push(); Matrix_Scale(player->unk_AF0[0].x, player->unk_AF0[0].y, player->unk_AF0[0].z, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, D_801C0AB4[arg2]); @@ -2936,7 +2936,7 @@ void func_80126BD0(PlayState* play, Player* player, s32 arg2) { Matrix_Push(); Matrix_Scale(player->unk_AF0[0].x, player->unk_AF0[0].y, player->unk_AF0[0].z, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, D_801C0ABC[arg2]); Matrix_MultVec3f(&D_801C0AC4[arg2], &sp58); @@ -2976,7 +2976,7 @@ s32 func_801271B0(PlayState* play, Player* player, s32 arg2) { func_80124618(sp3C[0], player->skelAnime.curFrame, &player->unk_AF0[1]); Matrix_Scale(player->unk_AF0[1].x, player->unk_AF0[1].y, player->unk_AF0[1].z, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, D_801C0B14[arg2]); @@ -2985,7 +2985,7 @@ s32 func_801271B0(PlayState* play, Player* player, s32 arg2) { func_80124618(sp3C[1], player->skelAnime.curFrame, &player->unk_AF0[1]); Matrix_Scale(player->unk_AF0[1].x, player->unk_AF0[1].y, player->unk_AF0[1].z, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); // Close flower / Open flower gSPDisplayList(POLY_OPA_DISP++, @@ -3021,7 +3021,7 @@ s32 func_80127438(PlayState* play, Player* player, s32 currentMask) { void func_80127488(PlayState* play, Player* player, u8 alpha) { OPEN_DISPS(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, alpha); gSPDisplayList(POLY_XLU_DISP++, gLinkGoronGoronPunchEffectDL); @@ -3062,7 +3062,7 @@ void Player_DrawCircusLeadersMask(PlayState* play, Player* player) { Matrix_Translate(D_801F59B0[i].x, D_801F59B0[i].y, D_801F59B0[i].z, MTXMODE_NEW); Matrix_Scale(scaleXZ, scaleY, scaleXZ, MTXMODE_APPLY); - gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(&gfx[0], Matrix_Finalize(play->state.gfxCtx), G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(&gfx[1], 0x08, OS_K0_TO_PHYSICAL(SEGMENTED_TO_K0(gEffBubble1Tex))); gDPSetPrimColor(&gfx[2], 0, 0, 255, 255, 255, 255); gDPSetEnvColor(&gfx[3], 150, 150, 150, 0); @@ -3466,7 +3466,7 @@ s32 func_80128640(PlayState* play, Player* player, Gfx* dList) { Matrix_Translate(-323.67f, 412.15f, -969.96f, MTXMODE_APPLY); Matrix_RotateZYX(-0x32BE, -0x50DE, -0x7717, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, D_801C0B20[mask - 1]); @@ -3483,7 +3483,7 @@ s32 func_80128640(PlayState* play, Player* player, Gfx* dList) { Matrix_RotateZYX(-0x8000, 0, 0x4000, MTXMODE_APPLY); Matrix_Scale(1.0f, player->unk_B0C, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, gDekuStickDL); Matrix_Pop(); @@ -3497,7 +3497,7 @@ s32 func_80128640(PlayState* play, Player* player, Gfx* dList) { Matrix_Push(); Matrix_Translate(temp_v1_2->x, temp_v1_2->y, temp_v1_2->z, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); // Note this does not check for PLAYER_BOTTLE_NONE, which would produce an OoB access on sPlayerBottleColors. // Under normal circunstances it should not be a problem because of the previous @@ -3524,7 +3524,7 @@ s32 func_80128640(PlayState* play, Player* player, Gfx* dList) { Matrix_RotateXS(sp26, MTXMODE_APPLY); Matrix_RotateYS(sp24, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, object_link_zora_DL_00E088); // hand Matrix_Pop(); @@ -3656,8 +3656,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, G } Matrix_Scale(1.0f, player->unk_B08, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, D_801C0D94); Matrix_Pop(); @@ -3765,8 +3764,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, G Matrix_Push(); Matrix_Scale(player->unk_AF0[1].x, player->unk_AF0[1].y, player->unk_AF0[1].z, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, object_link_goron_DL_00FC18); @@ -3776,8 +3774,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, G Matrix_Push(); Matrix_Scale(sp178[i].x, sp178[i].y, sp178[i].z, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, D_801C0DF0[i]); Matrix_Pop(); @@ -3823,8 +3820,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, G Matrix_Translate(temp_s0_4->x, temp_s0_4->z, 0.0f, MTXMODE_APPLY); Matrix_Scale(1.0f, 1.0f - player->unk_B10[3], 1.0f - player->unk_B10[2], MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); Matrix_Pop(); @@ -3848,8 +3844,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, G Matrix_Scale(player->unk_AF0[0].x, player->unk_AF0[0].y, player->unk_AF0[0].z, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, object_link_nuts_DL_00A348); Matrix_Pop(); @@ -3897,8 +3892,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, G Matrix_Push(); Matrix_Scale(player->arr_AF0[0], player->arr_AF0[0], player->arr_AF0[0], MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, object_link_nuts_DL_007390); Matrix_Pop(); @@ -3907,8 +3901,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, G Matrix_Push(); Matrix_Scale(spF0[i].x, spF0[i].y, spF0[i].z, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), - G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, play->state.gfxCtx); //! FAKE: (yes, all of them are required) // https://decomp.me/scratch/AdU3G if (1) {} @@ -3946,7 +3939,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, G Matrix_Scale(0.7f, 0.7f, 0.7f, MTXMODE_APPLY); } - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, (u8)player->av2.actionVar2); gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_054C90); diff --git a/src/code/z_room.c b/src/code/z_room.c index 70573b0c8..cb8d42666 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -22,14 +22,14 @@ void Room_DrawNormal(PlayState* play, Room* room, u32 flags) { func_800BCBF4(&sZeroVec, play); gSPSegment(POLY_OPA_DISP++, 0x03, room->segment); func_8012C268(&play->state); - gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); } if (flags & ROOM_DRAW_XLU) { func_800BCC68(&sZeroVec, play); gSPSegment(POLY_XLU_DISP++, 0x03, room->segment); Gfx_SetupDL25_Xlu(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); } roomShape = &room->roomShape->normal; @@ -89,7 +89,7 @@ void Room_DrawCullable(PlayState* play, Room* room, u32 flags) { gSPSegment(POLY_OPA_DISP++, 0x06, play->roomCtx.unk74); } func_8012C268(&play->state); - gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); } if (flags & ROOM_DRAW_XLU) { @@ -99,7 +99,7 @@ void Room_DrawCullable(PlayState* play, Room* room, u32 flags) { gSPSegment(POLY_XLU_DISP++, 0x06, play->roomCtx.unk74); } Gfx_SetupDL25_Xlu(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); } if (room->enablePosLights || (MREG(93) != 0)) { @@ -321,7 +321,7 @@ void Room_DrawImageSingle(PlayState* play, Room* room, u32 flags) { if (drawOpa) { Gfx_SetupDL25_Opa(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, entry->opa); } @@ -351,7 +351,7 @@ void Room_DrawImageSingle(PlayState* play, Room* room, u32 flags) { if (drawXlu) { gSPSegment(POLY_XLU_DISP++, 0x03, room->segment); Gfx_SetupDL25_Xlu(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, entry->xlu); } @@ -420,7 +420,7 @@ void Room_DrawImageMulti(PlayState* play, Room* room, u32 flags) { if (drawOpa) { Gfx_SetupDL25_Opa(play->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, dListsEntry->opa); } @@ -450,7 +450,7 @@ void Room_DrawImageMulti(PlayState* play, Room* room, u32 flags) { if (drawXlu) { gSPSegment(POLY_XLU_DISP++, 0x03, room->segment); Gfx_SetupDL25_Xlu(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, dListsEntry->xlu); } diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 6409a6a41..a5fee2859 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -51,7 +51,7 @@ void SkelAnime_DrawLimbLod(PlayState* play, s32 limbIndex, void** skeleton, Vec3 if (dList != NULL) { Gfx* gfx = POLY_OPA_DISP; - gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD); + MATRIX_FINALIZE_AND_LOAD(&gfx[0], play->state.gfxCtx); gSPDisplayList(&gfx[1], dList); POLY_OPA_DISP = &gfx[2]; @@ -108,7 +108,7 @@ void SkelAnime_DrawLod(PlayState* play, void** skeleton, Vec3s* jointTable, Over if (dList != NULL) { Gfx* gfx = POLY_OPA_DISP; - gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD); + MATRIX_FINALIZE_AND_LOAD(&gfx[0], play->state.gfxCtx); gSPDisplayList(&gfx[1], dList); @@ -161,7 +161,7 @@ void SkelAnime_DrawFlexLimbLod(PlayState* play, s32 limbIndex, void** skeleton, Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { Matrix_ToMtx(*mtx); - gSPMatrix(POLY_OPA_DISP++, *mtx, G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, *mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, newDList); (*mtx)++; } else if (limbDList != NULL) { @@ -228,7 +228,7 @@ void SkelAnime_DrawFlexLod(PlayState* play, void** skeleton, Vec3s* jointTable, if (newDList != NULL) { Gfx* gfx = POLY_OPA_DISP; - gSPMatrix(&gfx[0], Matrix_ToMtx(mtx), G_MTX_LOAD); + gSPMatrix(&gfx[0], Matrix_ToMtx(mtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[1], newDList); POLY_OPA_DISP = &gfx[2]; mtx++; @@ -279,7 +279,8 @@ void SkelAnime_DrawLimbOpa(PlayState* play, s32 limbIndex, void** skeleton, Vec3 if (dList != NULL) { Gfx* gfx = POLY_OPA_DISP; - gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD); + MATRIX_FINALIZE_AND_LOAD(&gfx[0], play->state.gfxCtx); + gSPDisplayList(&gfx[1], dList); POLY_OPA_DISP = &gfx[2]; } @@ -334,7 +335,8 @@ void SkelAnime_DrawOpa(PlayState* play, void** skeleton, Vec3s* jointTable, Over if (dList != NULL) { Gfx* gfx = POLY_OPA_DISP; - gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD); + MATRIX_FINALIZE_AND_LOAD(&gfx[0], play->state.gfxCtx); + gSPDisplayList(&gfx[1], dList); POLY_OPA_DISP = &gfx[2]; } @@ -380,7 +382,7 @@ void SkelAnime_DrawFlexLimbOpa(PlayState* play, s32 limbIndex, void** skeleton, Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { Matrix_ToMtx(*limbMatricies); - gSPMatrix(POLY_OPA_DISP++, *limbMatricies, G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, *limbMatricies, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, newDList); (*limbMatricies)++; } else if (limbDList != NULL) { @@ -447,7 +449,7 @@ void SkelAnime_DrawFlexOpa(PlayState* play, void** skeleton, Vec3s* jointTable, if (newDList != NULL) { Gfx* gfx = POLY_OPA_DISP; - gSPMatrix(&gfx[0], Matrix_ToMtx(mtx), G_MTX_LOAD); + gSPMatrix(&gfx[0], Matrix_ToMtx(mtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[1], newDList); POLY_OPA_DISP = &gfx[2]; mtx++; @@ -505,7 +507,7 @@ void SkelAnime_DrawTransformFlexLimbOpa(PlayState* play, s32 limbIndex, void** s if (newDList != NULL) { Gfx* gfx = POLY_OPA_DISP; - gSPMatrix(&gfx[0], Matrix_ToMtx(*mtx), G_MTX_LOAD); + gSPMatrix(&gfx[0], Matrix_ToMtx(*mtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[1], newDList); POLY_OPA_DISP = &gfx[2]; (*mtx)++; @@ -587,7 +589,7 @@ void SkelAnime_DrawTransformFlexOpa(PlayState* play, void** skeleton, Vec3s* joi if (newDList != NULL) { Gfx* gfx = POLY_OPA_DISP; - gSPMatrix(&gfx[0], Matrix_ToMtx(mtx), G_MTX_LOAD); + gSPMatrix(&gfx[0], Matrix_ToMtx(mtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[1], newDList); POLY_OPA_DISP = &gfx[2]; mtx++; @@ -675,7 +677,7 @@ Gfx* SkelAnime_DrawLimb(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &dList, &pos, &rot, actor, &gfx)) { Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { - gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD); + MATRIX_FINALIZE_AND_LOAD(&gfx[0], play->state.gfxCtx); gSPDisplayList(&gfx[1], dList); gfx = &gfx[2]; } @@ -729,7 +731,7 @@ Gfx* SkelAnime_Draw(PlayState* play, void** skeleton, Vec3s* jointTable, Overrid if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &dList, &pos, &rot, actor, &gfx)) { Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { - gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD); + MATRIX_FINALIZE_AND_LOAD(&gfx[0], play->state.gfxCtx); gSPDisplayList(&gfx[1], dList); gfx = &gfx[2]; } @@ -776,7 +778,7 @@ Gfx* SkelAnime_DrawFlexLimb(PlayState* play, s32 limbIndex, void** skeleton, Vec if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &newDList, &pos, &rot, actor, &gfx)) { Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { - gSPMatrix(&gfx[0], Matrix_ToMtx(*mtx), G_MTX_LOAD); + gSPMatrix(&gfx[0], Matrix_ToMtx(*mtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[1], newDList); gfx = &gfx[2]; (*mtx)++; @@ -845,7 +847,7 @@ Gfx* SkelAnime_DrawFlex(PlayState* play, void** skeleton, Vec3s* jointTable, s32 if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &newDList, &pos, &rot, actor, &gfx)) { Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { - gSPMatrix(&gfx[0], Matrix_ToMtx(mtx), G_MTX_LOAD); + gSPMatrix(&gfx[0], Matrix_ToMtx(mtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(&gfx[1], newDList); gfx = &gfx[2]; mtx++; diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 43ee1763e..f075883bb 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -1013,7 +1013,7 @@ void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex) { gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); Matrix_Translate(actor->world.pos.x, 0.0f, actor->world.pos.z, MTXMODE_NEW); Matrix_Scale(0.6f, 1.0f, 0.6f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + MATRIX_FINALIZE_AND_LOAD(POLY_OPA_DISP++, gfxCtx); gSPDisplayList(POLY_OPA_DISP++, gShadowMaterialDL); gDPLoadTextureBlock(POLY_OPA_DISP++, tex, G_IM_FMT_I, G_IM_SIZ_8b, SUBS_SHADOW_TEX_WIDTH, SUBS_SHADOW_TEX_HEIGHT, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD); -- cgit v1.2.3