diff --git a/patches/init_patches.c b/patches/init_patches.c index 4a43d84..f67deab 100644 --- a/patches/init_patches.c +++ b/patches/init_patches.c @@ -1,4 +1,5 @@ #include "patches.h" +#include "transform_ids.h" #include "bk_api.h" #include "misc_funcs.h" @@ -16,6 +17,8 @@ RECOMP_PATCH void mainThread_entry(void *arg) { sns_write_payload_over_heap(); while (1) { + // @recomp Reset the tracked projection IDs. + reset_projection_ids(); mainLoop(); } } diff --git a/patches/marker_transform_tagging.c b/patches/marker_transform_tagging.c index e395ff0..d5cfb35 100644 --- a/patches/marker_transform_tagging.c +++ b/patches/marker_transform_tagging.c @@ -18,12 +18,13 @@ RECOMP_PATCH void player_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx) { eggShatter_draw(gfx, mtx, vtx); // @recomp Set the current transform ID to banjo's. + u32 prev_transform_id = cur_drawn_model_transform_id; cur_drawn_model_transform_id = BANJO_TRANSFORM_ID_START; baModel_draw(gfx, mtx, vtx); - // @recomp Clear the current transform ID. - cur_drawn_model_transform_id = 0; + // @recomp Reset the current transform ID. + cur_drawn_model_transform_id = prev_transform_id; } } @@ -34,13 +35,16 @@ RECOMP_PATCH void __marker_draw(ActorMarker *this, Gfx **gfx, Mtx **mtx, Vtx **v f32 draw_dist_f; f32 percentage; - // @recomp Set the current drawn marker's transform ID. + // @recomp Calculate the current drawn marker's transform ID. s32 cur_drawn_marker_spawn_index = bkrecomp_get_marker_spawn_index(this); - cur_drawn_model_transform_id = MARKER_TRANSFORM_ID_START + cur_drawn_marker_spawn_index * MARKER_TRANSFORM_ID_COUNT; + u32 prev_transform_id = cur_drawn_model_transform_id; + u32 transform_id = MARKER_TRANSFORM_ID_START + cur_drawn_marker_spawn_index * MARKER_TRANSFORM_ID_COUNT; if(!this->unk3E_0){ + // @recomp Set the current drawn marker's transform ID. + cur_drawn_model_transform_id = transform_id; this->drawFunc(this, gfx, mtx, vtx); // @recomp Clear the current transform ID after drawing. - cur_drawn_model_transform_id = 0; + cur_drawn_model_transform_id = prev_transform_id; return; } actor = marker_getActor(this); @@ -61,9 +65,11 @@ RECOMP_PATCH void __marker_draw(ActorMarker *this, Gfx **gfx, Mtx **mtx, Vtx **v percentage = 1.0f; } func_8033A280(percentage); + // @recomp Set the current drawn marker's transform ID. + cur_drawn_model_transform_id = transform_id; this->drawFunc(this, gfx, mtx, vtx); // @recomp Set the current drawn marker to null after drawing. - cur_drawn_model_transform_id = 0; + cur_drawn_model_transform_id = prev_transform_id; }//L8032D300 func_8033A244(30000.0f); func_8033A280(1.0f); diff --git a/patches/projection_transform_tagging.c b/patches/projection_transform_tagging.c index 608e483..9737d52 100644 --- a/patches/projection_transform_tagging.c +++ b/patches/projection_transform_tagging.c @@ -270,7 +270,38 @@ RECOMP_PATCH Actor *func_802DC320(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx return this; } -// @recomp Patched to set the zoombox portrait's ortho projection transform ID. +// @recomp Patched to set the zoombox's model transform ID. +RECOMP_PATCH void func_803163A8(GcZoombox *this, Gfx **gfx, Mtx **mtx) { + f32 sp5C[3]; + f32 sp50[3]; + f32 sp44[3]; + f32 sp38[3]; + f32 sp34; + + sp34 = viewport_transformCoordinate(this->unk170, this->unk172, sp50, sp5C); + if (this->unk1A4_24) { + sp5C[1] += 180.0f; + sp5C[0] -= 2*sp5C[0]; + } + sp38[0] = 0.0f; sp38[1] = 0.0f; sp38[2] = 0.0f; + sp44[0] = 0.0f; sp44[1] = 0.0f; sp44[2] = 0.0f; + func_8033A308(sp44); + modelRender_setDepthMode(MODEL_RENDER_DEPTH_NONE); + if (this->anim_ctrl != NULL) { + anctrl_drawSetup(this->anim_ctrl, sp50, 1); + } + + // @recomp Set the model transform ID. + u32 prev_transform_id = cur_drawn_model_transform_id; + cur_drawn_model_transform_id = ZOOMBOX_TRANSFORM_ID_START + this->portrait_id; + + modelRender_draw(gfx, mtx, sp50, sp5C, this->unk198 * sp34, sp38, this->model); + + // @recomp Reset the model transform ID. + cur_drawn_model_transform_id = prev_transform_id; +} + +// @recomp Patched to set the zoombox portrait's model and ortho projection transform IDs. RECOMP_PATCH void func_803164B0(GcZoombox *this, Gfx **gfx, Mtx **mtx, s32 arg3, s32 arg4, BKSpriteDisplayData *arg5, f32 arg6) { f32 sp2C[3]; f32 temp_f12; @@ -305,8 +336,15 @@ RECOMP_PATCH void func_803164B0(GcZoombox *this, Gfx **gfx, Mtx **mtx, s32 arg3, mlMtxScale_xyz(temp_f12, temp_f12, 1.0f); mlMtxApply(*mtx); gSPMatrix((*gfx)++, (*mtx)++, G_MTX_LOAD | G_MTX_MODELVIEW); + + // @recomp Create a matrix group for the portrait's model matrix. + gEXMatrixGroupDecomposedVerts((*gfx)++, ZOOMBOX_PORTRAIT_TRANSFORM_ID_START + this->portrait_id, G_EX_PUSH, G_MTX_MODELVIEW, G_EX_EDIT_NONE); + modelRender_setDepthMode(MODEL_RENDER_DEPTH_NONE); func_80344090(arg5, this->unk186, gfx); func_8033687C(gfx); viewport_setRenderViewportAndPerspectiveMatrix(gfx, mtx); + + // @recomp Pop the model matrix group. + gEXPopMatrixGroup((*gfx)++, G_MTX_MODELVIEW); }