From 899bbb205e418f638f10e9f1a96b229ce3211727 Mon Sep 17 00:00:00 2001 From: Mr-Wiseguy Date: Sun, 24 Dec 2023 02:01:22 -0500 Subject: [PATCH] Added origin adjustment for item equip animation in pause screen, disabled some WIP patches --- patches/camera_patches.c | 12 +++-------- patches/culling.c | 43 ++++++++++++++++++++++++++++++++++++++++ patches/input.c | 3 ++- patches/ui_patches.c | 33 ++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 10 deletions(-) diff --git a/patches/camera_patches.c b/patches/camera_patches.c index 1e21e4c..32365a1 100644 --- a/patches/camera_patches.c +++ b/patches/camera_patches.c @@ -1,8 +1,8 @@ #include "patches.h" #include "input.h" #include "z64quake.h" - -RecompCameraMode recomp_camera_mode = RECOMP_CAMERA_DUALANALOG; +#if 0 +RecompCameraMode recomp_camera_mode = RECOMP_CAMERA_NORMAL; VecGeo recomp_camera_pos = { .r = 66.0f, .pitch = 0, .yaw = 0 }; @@ -272,11 +272,6 @@ Vec3s Camera_Update(Camera* camera) { } // Call the camera update function - recomp_printf( - "Camera:\n" - " setting: %d\n" - " mode: %d\n" - " funcId: %d\n", camera->setting, camera->mode, sCameraSettings[camera->setting].cameraModes[camera->mode].funcId); sCameraUpdateHandlers[sCameraSettings[camera->setting].cameraModes[camera->mode].funcId](camera); // @recomp @@ -411,8 +406,6 @@ s32 Camera_Normal1(Camera* camera) { f32 phi_f2; f32 rand; - recomp_printf("Camera_Normal1\n"); - roData->unk_00 = GET_NEXT_RO_DATA(values) * (sp88 * 0.01f * (0.8f - ((68.0f / sp88) * -0.2f))); roData->unk_04 = GET_NEXT_RO_DATA(values) * (sp88 * 0.01f * (0.8f - ((68.0f / sp88) * -0.2f))); roData->unk_08 = GET_NEXT_RO_DATA(values) * (sp88 * 0.01f * (0.8f - ((68.0f / sp88) * -0.2f))); @@ -790,3 +783,4 @@ s32 Camera_Normal1(Camera* camera) { return true; } +#endif // #if 0 diff --git a/patches/culling.c b/patches/culling.c index 4734c1c..4084123 100644 --- a/patches/culling.c +++ b/patches/culling.c @@ -29,6 +29,49 @@ s32 func_800BA2FC(PlayState* play, Actor* actor, Vec3f* projectedPos, f32 projec return false; } +// Disable frustum culling for bush spawning +// s32 EnWood02_SpawnZoneCheck(EnWood02* this, PlayState* play, Vec3f* arg2) { +// f32 phi_f12; + +// SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, arg2, &this->actor.projectedPos, &this->actor.projectedW); + +// if (this->actor.projectedW == 0.0f) { +// phi_f12 = 1000.0f; +// } else { +// phi_f12 = fabsf(1.0f / this->actor.projectedW); +// } + +// if (((-this->actor.uncullZoneScale < this->actor.projectedPos.z) && +// (this->actor.projectedPos.z < (this->actor.uncullZoneForward + this->actor.uncullZoneScale)) /* && +// (((fabsf(this->actor.projectedPos.x) - this->actor.uncullZoneScale) * phi_f12) < 1.0f)) && +// (((this->actor.projectedPos.y + this->actor.uncullZoneDownward) * phi_f12) > -1.0f) && +// (((this->actor.projectedPos.y - this->actor.uncullZoneScale) * phi_f12) < 1.0f */)) { +// return true; +// } +// return false; +// } + +// Disable frustum culling for grass +s32 func_809A9110(PlayState* play, Vec3f* pos) { + f32 w; + Vec3f projectedPos; + + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, pos, &projectedPos, &w); + + if ((play->projectionMtxFDiagonal.z * -130.13191f) < projectedPos.z) { + if (w < 1.0f) { + w = 1.0f; + } + + // if (((fabsf(projectedPos.x) - (130.13191f * play->projectionMtxFDiagonal.x)) < w) && + // ((fabsf(projectedPos.y) - (130.13191f * play->projectionMtxFDiagonal.y)) < w)) { + return true; + // } + } + return false; +} + + // Override LOD to 0 void Player_DrawGameplay(PlayState* play, Player* this, s32 lod, Gfx* cullDList, OverrideLimbDrawFlex overrideLimbDraw) { diff --git a/patches/input.c b/patches/input.c index 5356326..eccf601 100644 --- a/patches/input.c +++ b/patches/input.c @@ -1,6 +1,6 @@ #include "patches.h" #include "input.h" - +#if 0 u32 sPlayerItemButtons[] = { BTN_B, BTN_CLEFT, @@ -154,3 +154,4 @@ ItemId Player_GetItemOnButton(PlayState* play, Player* player, EquipSlot slot) { return C_BTN_ITEM(EQUIP_SLOT_C_RIGHT); } */ +#endif // #if 0 diff --git a/patches/ui_patches.c b/patches/ui_patches.c index bf0b1ef..a6daf79 100644 --- a/patches/ui_patches.c +++ b/patches/ui_patches.c @@ -389,6 +389,39 @@ void Interface_Draw(PlayState* play) { Interface_DrawAButton(play); + // @recomp Move the item being equipped from the center of the screen to the right edge as the timer counts down + if (gKaleidoMgrOverlayTable[0].loadedRamAddr != NULL) { + // These are overlay symbols, so their addresses need to be offset to get their actual loaded vram address. + // TODO remove this once the recompiler is able to handle overlay symbols automatically for patch functions. + extern s16 sEquipAnimTimer; + extern s16 sMaskEquipAnimTimer; + extern s16 sEquipState; + extern s16 sMaskEquipState; + s16 equip_timer = *(s16*)((u8*)&sEquipAnimTimer + gKaleidoMgrOverlayTable[0].offset); + s16 mask_equip_timer = *(s16*)((u8*)&sMaskEquipAnimTimer + gKaleidoMgrOverlayTable[0].offset); + s16 equip_state = *(s16*)((u8*)&sEquipState + gKaleidoMgrOverlayTable[0].offset); + s16 mask_equip_state = *(s16*)((u8*)&sMaskEquipState + gKaleidoMgrOverlayTable[0].offset); + + s16 timer = MIN(equip_timer, mask_equip_timer); + s32 max_timer = 10; + + // Prevent the timer from being used to calculate the origin when an arrow effect is taking place. + if (equip_timer < 10 && equip_state != EQUIP_STATE_MOVE_TO_C_BTN) { + timer = 10; + } + + // Adjust the max timer value if a magic arrow is being equipped. + if ((pauseCtx->equipTargetItem == ITEM_BOW_FIRE) || + (pauseCtx->equipTargetItem == ITEM_BOW_ICE) || + (pauseCtx->equipTargetItem == ITEM_BOW_LIGHT)) { + max_timer = 6; + } + + s32 origin = (G_EX_ORIGIN_CENTER - G_EX_ORIGIN_RIGHT) * (timer - 1) / (max_timer - 1) + G_EX_ORIGIN_RIGHT; + s32 offset = (SCREEN_WIDTH / 2) * (timer - 1) / (max_timer - 1) - SCREEN_WIDTH; + gEXSetRectAlign(OVERLAY_DISP++, origin, origin, offset * 4, 0, offset * 4, 0); + gEXSetViewportAlign(OVERLAY_DISP++, origin, offset * 4, 0); + } Interface_DrawPauseMenuEquippingIcons(play); // Draw either the minigame countdown or the three-day clock