From 0e7aa47b1152e98a60c480ed5adc350c03b4dc9c Mon Sep 17 00:00:00 2001 From: Mr-Wiseguy Date: Sun, 3 Mar 2024 02:59:41 -0500 Subject: [PATCH] Transform tagging for the hookshot reticle --- patches/item_transform_tagging.c | 49 ++++++++++++++++++++++++++++++++ patches/transform_ids.h | 1 + 2 files changed, 50 insertions(+) diff --git a/patches/item_transform_tagging.c b/patches/item_transform_tagging.c index f4a2691..3bf482c 100644 --- a/patches/item_transform_tagging.c +++ b/patches/item_transform_tagging.c @@ -76,6 +76,55 @@ void ArmsHook_Draw(Actor* thisx, PlayState* play) { #undef THIS +extern Gfx gHookshotReticleDL[]; +void Player_DrawHookshotReticle(PlayState* play, Player* player, f32 hookshotDistance) { + static Vec3f D_801C094C = { -500.0f, -100.0f, 0.0f }; + CollisionPoly* poly; + s32 bgId; + Vec3f sp7C; + Vec3f sp70; + Vec3f pos; + + D_801C094C.z = 0.0f; + Matrix_MultVec3f(&D_801C094C, &sp7C); + D_801C094C.z = hookshotDistance; + Matrix_MultVec3f(&D_801C094C, &sp70); + + if (BgCheck_AnyLineTest3(&play->colCtx, &sp7C, &sp70, &pos, &poly, true, true, true, true, &bgId)) { + if (!func_800B90AC(play, &player->actor, poly, bgId, &pos) || + BgCheck_ProjectileLineTest(&play->colCtx, &sp7C, &sp70, &pos, &poly, true, true, true, true, &bgId)) { + Vec3f sp58; + f32 sp54; + f32 scale; + + OPEN_DISPS(play->state.gfxCtx); + + OVERLAY_DISP = Gfx_SetupDL(OVERLAY_DISP, SETUPDL_7); + + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &pos, &sp58, &sp54); + + scale = (sp54 < 200.0f) ? 0.08f : (sp54 / 200.0f) * 0.08f; + + Matrix_Translate(pos.x, pos.y, pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + + // @recomp Tag the reticle's transform. + gEXMatrixGroupSimple(OVERLAY_DISP++, HOOKSHOT_RETICLE_ID, G_EX_PUSH, G_MTX_MODELVIEW, + G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_COMPONENT_INTERPOLATE, G_EX_ORDER_LINEAR); + + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPSegment(OVERLAY_DISP++, 0x06, play->objectCtx.slots[player->actor.objectSlot].segment); + gSPDisplayList(OVERLAY_DISP++, gHookshotReticleDL); + + // @recomp Pop the reticle's transform tag. + gEXPopMatrixGroup(OVERLAY_DISP); + + CLOSE_DISPS(play->state.gfxCtx); + } + } +} + extern Gfx object_link_child_DL_017818[]; diff --git a/patches/transform_ids.h b/patches/transform_ids.h index 3a29f31..bb14e86 100644 --- a/patches/transform_ids.h +++ b/patches/transform_ids.h @@ -11,6 +11,7 @@ #define SOARING_CAPSULE_TRANSFORM_ID 0x301U #define BOWSTRING_TRANSFORM_ID 0x400U +#define HOOKSHOT_RETICLE_ID 0x401U #define ACTOR_TRANSFORM_LIMB_COUNT 128 #define ACTOR_TRANSFORM_ID_COUNT (ACTOR_TRANSFORM_LIMB_COUNT * 2) // One ID for each limb and another for each post-draw