From 775501b28bcac057c9054cba70e28ecbb8f48d5e Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Wed, 27 Sep 2023 07:24:12 +1000 Subject: [PATCH 1/9] Animation Cleanup: En_G* (#1395) * wip * more cleanup * more cleanup * one more thing * one more default case * missed brackets * PR Review --- src/overlays/actors/ovl_En_Gb2/z_en_gb2.c | 65 +++-- src/overlays/actors/ovl_En_Gb2/z_en_gb2.h | 5 +- src/overlays/actors/ovl_En_Ge1/z_en_ge1.c | 11 +- src/overlays/actors/ovl_En_Ge2/z_en_ge2.c | 41 +-- src/overlays/actors/ovl_En_Ge3/z_en_ge3.c | 6 +- src/overlays/actors/ovl_En_Geg/z_en_geg.c | 151 ++++++---- src/overlays/actors/ovl_En_Geg/z_en_geg.h | 7 +- src/overlays/actors/ovl_En_Gg/z_en_gg.c | 192 ++++++++----- src/overlays/actors/ovl_En_Gg/z_en_gg.h | 11 +- src/overlays/actors/ovl_En_Gg2/z_en_gg2.c | 110 ++++--- src/overlays/actors/ovl_En_Gg2/z_en_gg2.h | 7 +- src/overlays/actors/ovl_En_Giant/z_en_giant.c | 147 +++++----- .../actors/ovl_En_Ginko_Man/z_en_ginko_man.c | 26 +- .../actors/ovl_En_Ginko_Man/z_en_ginko_man.h | 5 +- src/overlays/actors/ovl_En_Gk/z_en_gk.c | 271 +++++++++++------- src/overlays/actors/ovl_En_Gk/z_en_gk.h | 9 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 211 ++++++++------ src/overlays/actors/ovl_En_Gm/z_en_gm.h | 9 +- src/overlays/actors/ovl_En_Go/z_en_go.c | 86 +++--- src/overlays/actors/ovl_En_Go/z_en_go.h | 4 +- .../actors/ovl_En_Goroiwa/z_en_goroiwa.c | 8 +- .../ovl_En_Grasshopper/z_en_grasshopper.c | 24 +- .../ovl_En_Grasshopper/z_en_grasshopper.h | 2 +- src/overlays/actors/ovl_En_Gs/z_en_gs.c | 41 ++- .../ovl_En_Guard_Nuts/z_en_guard_nuts.c | 69 +++-- .../ovl_En_Guard_Nuts/z_en_guard_nuts.h | 2 +- .../actors/ovl_En_Guruguru/z_en_guruguru.c | 35 ++- .../actors/ovl_En_Guruguru/z_en_guruguru.h | 7 +- src/overlays/actors/ovl_En_Jg/z_en_jg.c | 29 +- src/overlays/actors/ovl_En_Jg/z_en_jg.h | 2 +- src/overlays/actors/ovl_En_Kgy/z_en_kgy.c | 6 +- src/overlays/actors/ovl_En_Mnk/z_en_mnk.c | 18 +- .../actors/ovl_En_Railgibud/z_en_railgibud.c | 21 +- .../actors/ovl_En_Railgibud/z_en_railgibud.h | 2 +- tools/disasm/functions.txt | 10 +- tools/disasm/variables.txt | 2 +- 36 files changed, 976 insertions(+), 676 deletions(-) diff --git a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c index 9b96771be..36e18e350 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.c @@ -5,7 +5,6 @@ */ #include "z_en_gb2.h" -#include "objects/object_ps/object_ps.h" #define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_FRIENDLY | ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -163,7 +162,7 @@ u16 func_80B0F7FC(EnGb2* this) { return 0x14E4; } - if (gSaveContext.save.saveInfo.playerData.health > 48) { + if (gSaveContext.save.saveInfo.playerData.health > 0x30) { return 0x14D2; } @@ -171,7 +170,7 @@ u16 func_80B0F7FC(EnGb2* this) { return 0x14D3; case 0x14E4: - if (gSaveContext.save.saveInfo.playerData.health > 48) { + if (gSaveContext.save.saveInfo.playerData.health > 0x30) { return 0x14D2; } @@ -193,8 +192,10 @@ u16 func_80B0F7FC(EnGb2* this) { case 0x14D9: return 0x14DA; + + default: + return 0; } - return 0; } u16 func_80B0F8F8(EnGb2* this) { @@ -213,8 +214,10 @@ u16 func_80B0F8F8(EnGb2* this) { case 0x14E1: return 0x14E2; + + default: + return 0; } - return 0; } u16 func_80B0F97C(EnGb2* this) { @@ -236,8 +239,10 @@ u16 func_80B0F97C(EnGb2* this) { case 0x14FA: this->unk_26C |= 2; return 0x14FB; + + default: + return 0; } - return 0; } void func_80B0FA04(EnGb2* this) { @@ -262,17 +267,19 @@ s32 func_80B0FA48(EnGb2* this, PlayState* play) { if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_80_40)) { this->unk_26E = 0x14EB; return false; + } else { + this->unk_26E = 0x14EE; + return true; } - this->unk_26E = 0x14EE; - return true; - } - if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_80_20)) { - this->unk_26E = 0x14EF; - return false; - } else { - this->unk_26E = 0x14F4; - return true; + default: + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_80_20)) { + this->unk_26E = 0x14EF; + return false; + } else { + this->unk_26E = 0x14F4; + return true; + } } } @@ -314,12 +321,14 @@ u16 func_80B0FB24(EnGb2* this) { case 0x14F2: this->unk_26C |= 2; return 0x14F3; + + default: + return 0; } - return 0; } void func_80B0FBF0(EnGb2* this, PlayState* play) { - Vec3f sp90[4] = { + Vec3f sp90[] = { { 120.0f, 0.0f, 800.0f }, { -120.0f, 0.0f, 750.0f }, { 60.0f, 0.0f, 750.0f }, @@ -425,6 +434,9 @@ void func_80B0FFA8(EnGb2* this, PlayState* play) { this->unk_26C |= 2; Message_StartTextbox(play, this->unk_26E, &this->actor); break; + + default: + break; } } else if (this->unk_26E == 0x14DA) { switch (play->msgCtx.choiceIndex) { @@ -443,6 +455,9 @@ void func_80B0FFA8(EnGb2* this, PlayState* play) { this->unk_26C |= 2; Message_StartTextbox(play, this->unk_26E, &this->actor); break; + + default: + break; } } } @@ -505,7 +520,7 @@ void func_80B10344(EnGb2* this, PlayState* play) { } } - if (gSaveContext.save.saveInfo.playerData.health < 49) { + if (gSaveContext.save.saveInfo.playerData.health <= 0x30) { gSaveContext.timerStates[TIMER_ID_MINIGAME_1] = TIMER_STATE_STOP; SET_EVENTINF(EVENTINF_46); SET_EVENTINF(EVENTINF_45); @@ -596,6 +611,9 @@ void func_80B10634(EnGb2* this, PlayState* play) { this->unk_26C |= 2; Message_StartTextbox(play, this->unk_26E, &this->actor); break; + + default: + break; } } } @@ -673,6 +691,9 @@ void func_80B10A48(EnGb2* this, PlayState* play) { this->actor.flags &= ~ACTOR_FLAG_TARGETABLE; this->actionFunc = func_80B111AC; break; + + default: + break; } } } @@ -877,7 +898,7 @@ void EnGb2_Init(Actor* thisx, PlayState* play) { this->actor.room = -1; Actor_ProcessInitChain(&this->actor, sInitChain); SkelAnime_InitFlex(play, &this->skelAnime, &object_ps_Skel_007230, &object_ps_Anim_00049C, this->jointTable, - this->morphTable, 12); + this->morphTable, OBJECT_PS_LIMB_MAX); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); Collider_InitCylinder(play, &this->collider); Collider_SetCylinderType1(play, &this->collider, &this->actor, &sCylinderInit); @@ -981,11 +1002,11 @@ s32 EnGb2_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p Gfx** gfx) { EnGb2* this = THIS; - if (limbIndex == 7) { + if (limbIndex == OBJECT_PS_LIMB_07) { Matrix_RotateYS(this->unk_270.y, MTXMODE_APPLY); } - if (limbIndex == 1) { + if (limbIndex == OBJECT_PS_LIMB_01) { *dList = NULL; } @@ -996,7 +1017,7 @@ void EnGb2_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, EnGb2* this = THIS; Vec3f sp18 = { 2400.0f, 0.0f, 0.0f }; - if (limbIndex == 7) { + if (limbIndex == OBJECT_PS_LIMB_07) { Matrix_MultVec3f(&sp18, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.h b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.h index a257ab3d4..fa500f15c 100644 --- a/src/overlays/actors/ovl_En_Gb2/z_en_gb2.h +++ b/src/overlays/actors/ovl_En_Gb2/z_en_gb2.h @@ -2,6 +2,7 @@ #define Z_EN_GB2_H #include "global.h" +#include "objects/object_ps/object_ps.h" struct EnGb2; @@ -19,8 +20,8 @@ typedef enum { typedef struct EnGb2 { /* 0x0000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s jointTable[12]; - /* 0x1D0 */ Vec3s morphTable[12]; + /* 0x188 */ Vec3s jointTable[OBJECT_PS_LIMB_MAX]; + /* 0x1D0 */ Vec3s morphTable[OBJECT_PS_LIMB_MAX]; /* 0x218 */ EnGb2ActionFunc actionFunc; /* 0x21C */ ColliderCylinder collider; /* 0x268 */ Actor* unk_268; diff --git a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c index 25556fdf7..c83305a8c 100644 --- a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c +++ b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c @@ -69,10 +69,11 @@ typedef enum { /* 6 */ GERUDO_WHITE_ANIM_EXCITED_CLAPPING, /* 7 */ GERUDO_WHITE_ANIM_SALUTE, /* 8 */ GERUDO_WHITE_ANIM_LEADING_BOAT, - /* 9 */ GERUDO_WHITE_ANIM_BLOWN_AWAY + /* 9 */ GERUDO_WHITE_ANIM_BLOWN_AWAY, + /* 10 */ GERUDO_WHITE_ANIM_MAX } GerudoWhiteAnimation; -void EnGe1_ChangeAnim(EnGe1* this, s16 animIndex, u8 mode, f32 morphFrames); +void EnGe1_ChangeAnim(EnGe1* this, s16 animIndex, u8 animMode, f32 morphFrames); void EnGe1_ShadowDraw(Actor* thisx, Lights* lights, PlayState* play); void EnGe1_Wait(EnGe1* this, PlayState* play); void EnGe1_PerformCutsceneActions(EnGe1* this, PlayState* play); @@ -127,8 +128,8 @@ void EnGe1_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->collider); } -void EnGe1_ChangeAnim(EnGe1* this, s16 animIndex, u8 mode, f32 morphFrames) { - static AnimationHeader* sAnimations[] = { +void EnGe1_ChangeAnim(EnGe1* this, s16 animIndex, u8 animMode, f32 morphFrames) { + static AnimationHeader* sAnimations[GERUDO_WHITE_ANIM_MAX] = { &gGerudoWhiteArmsFoldedAnim, // GERUDO_WHITE_ANIM_ARMS_FOLDED, &gGerudoWhiteUnfoldingArmsAnim, // GERUDO_WHITE_ANIM_UNFOLDING_ARMS &gGerudoWhiteStandingHeadBowedAnim, // GERUDO_WHITE_ANIM_STANDING_HEAD_BOWED, @@ -154,7 +155,7 @@ void EnGe1_ChangeAnim(EnGe1* this, s16 animIndex, u8 mode, f32 morphFrames) { default: Animation_Change(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimations[animIndex]), mode, morphFrames); + Animation_GetLastFrame(sAnimations[animIndex]), animMode, morphFrames); break; } diff --git a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c index eeacf00a5..45d304aaf 100644 --- a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c +++ b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c @@ -119,7 +119,7 @@ void EnGe2_Init(Actor* thisx, PlayState* play) { switch (GERUDO_PURPLE_GET_TYPE(&this->picto.actor)) { case GERUDO_PURPLE_TYPE_BOAT_SENTRY: Animation_Change(&this->skelAnime, &gGerudoPurpleLookingAboutAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGerudoPurpleLookingAboutAnim), 0, 0.0f); + Animation_GetLastFrame(&gGerudoPurpleLookingAboutAnim), ANIMMODE_LOOP, 0.0f); this->actionFunc = EnGe2_GuardStationary; this->picto.actor.speed = 0.0f; this->picto.actor.uncullZoneForward = 4000.0f; @@ -343,18 +343,18 @@ s32 EnGe2_FollowPathWithoutGravity(EnGe2* this) { /* Action and helper functions */ void EnGe2_SpawnEffects(EnGe2* this, PlayState* play) { - static Vec3f effectVelocity = { 0.0f, -0.05f, 0.0f }; - static Vec3f effectAccel = { 0.0f, -0.025f, 0.0f }; - static Color_RGBA8 effectPrimColor = { 255, 255, 255, 0 }; - static Color_RGBA8 effectEnvColor = { 255, 150, 0, 0 }; + static Vec3f sEffectVelocity = { 0.0f, -0.05f, 0.0f }; + static Vec3f sEffectAccel = { 0.0f, -0.025f, 0.0f }; + static Color_RGBA8 sEffectPrimColor = { 255, 255, 255, 0 }; + static Color_RGBA8 sEffectEnvColor = { 255, 150, 0, 0 }; s16 effectAngle = play->state.frames * 0x2800; Vec3f effectPos; effectPos.x = (Math_CosS(effectAngle) * 5.0f) + this->picto.actor.focus.pos.x; effectPos.y = this->picto.actor.focus.pos.y + 10.0f; effectPos.z = (Math_SinS(effectAngle) * 5.0f) + this->picto.actor.focus.pos.z; - EffectSsKirakira_SpawnDispersed(play, &effectPos, &effectVelocity, &effectAccel, &effectPrimColor, &effectEnvColor, - 1000, 16); + EffectSsKirakira_SpawnDispersed(play, &effectPos, &sEffectVelocity, &sEffectAccel, &sEffectPrimColor, + &sEffectEnvColor, 1000, 16); } void EnGe2_Scream(EnGe2* this) { @@ -396,7 +396,7 @@ void EnGe2_SetupCapturePlayer(EnGe2* this) { this->picto.actor.speed = 0.0f; this->actionFunc = EnGe2_CapturePlayer; Animation_Change(&this->skelAnime, &gGerudoPurpleLookingAboutAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGerudoPurpleLookingAboutAnim), 0, -8.0f); + Animation_GetLastFrame(&gGerudoPurpleLookingAboutAnim), ANIMMODE_LOOP, -8.0f); } void EnGe2_Charge(EnGe2* this, PlayState* play) { @@ -429,7 +429,7 @@ void EnGe2_SetupCharge(EnGe2* this, PlayState* play) { if (this->picto.actor.shape.rot.y == this->picto.actor.yawTowardsPlayer) { Animation_Change(&this->skelAnime, &gGerudoPurpleChargingAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGerudoPurpleChargingAnim), 0, -8.0f); + Animation_GetLastFrame(&gGerudoPurpleChargingAnim), ANIMMODE_LOOP, -8.0f); this->timer = 50; this->picto.actor.speed = 4.0f; this->actionFunc = EnGe2_Charge; @@ -438,7 +438,7 @@ void EnGe2_SetupCharge(EnGe2* this, PlayState* play) { void EnGe2_SetupLookAround(EnGe2* this) { Animation_Change(&this->skelAnime, &gGerudoPurpleLookingAboutAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGerudoPurpleLookingAboutAnim), 0, -8.0f); + Animation_GetLastFrame(&gGerudoPurpleLookingAboutAnim), ANIMMODE_LOOP, -8.0f); this->timer = 60; this->picto.actor.speed = 0.0f; this->actionFunc = EnGe2_LookAround; @@ -483,13 +483,13 @@ void EnGe2_PatrolDuties(EnGe2* this, PlayState* play) { this->picto.actor.speed = 0.0f; this->actionFunc = EnGe2_SetupCharge; Animation_Change(&this->skelAnime, &gGerudoPurpleLookingAboutAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGerudoPurpleLookingAboutAnim), 0, -8.0f); + Animation_GetLastFrame(&gGerudoPurpleLookingAboutAnim), ANIMMODE_LOOP, -8.0f); this->stateFlags |= GERUDO_PURPLE_STATE_CAPTURING; } else if (CHECK_WEEKEVENTREG(WEEKEVENTREG_80_08)) { this->picto.actor.speed = 0.0f; this->actionFunc = EnGe2_TurnToPlayerFast; Animation_Change(&this->skelAnime, &gGerudoPurpleLookingAboutAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGerudoPurpleLookingAboutAnim), 0, -8.0f); + Animation_GetLastFrame(&gGerudoPurpleLookingAboutAnim), ANIMMODE_LOOP, -8.0f); } else if (EnGe2_LookForPlayer(play, &this->picto.actor, &this->picto.actor.focus.pos, this->picto.actor.shape.rot.y, 0x1800, visionRange, this->verticalDetectRange)) { if ((GERUDO_PURPLE_GET_EXIT(&this->picto.actor) != GERUDO_PURPLE_EXIT_NONE) && !Play_InCsMode(play)) { @@ -499,7 +499,7 @@ void EnGe2_PatrolDuties(EnGe2* this, PlayState* play) { Message_StartTextbox(play, 0x1194, &this->picto.actor); this->actionFunc = EnGe2_SetupCharge; Animation_Change(&this->skelAnime, &gGerudoPurpleLookingAboutAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGerudoPurpleLookingAboutAnim), 0, -8.0f); + Animation_GetLastFrame(&gGerudoPurpleLookingAboutAnim), ANIMMODE_LOOP, -8.0f); } } else if (this->collider.base.acFlags & AC_HIT) { if ((this->collider.info.acHitInfo != NULL) && @@ -510,7 +510,7 @@ void EnGe2_PatrolDuties(EnGe2* this, PlayState* play) { this->stateFlags |= GERUDO_PURPLE_STATE_STUNNED; } else { Animation_Change(&this->skelAnime, &gGerudoPurpleFallingToGroundAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGerudoPurpleFallingToGroundAnim), 2, -8.0f); + Animation_GetLastFrame(&gGerudoPurpleFallingToGroundAnim), ANIMMODE_ONCE, -8.0f); this->timer = 200; this->picto.actor.speed = 0.0f; this->actionFunc = EnGe2_KnockedOut; @@ -543,7 +543,7 @@ void EnGe2_LookAround(EnGe2* this, PlayState* play) { } else { this->actionFunc = EnGe2_Walk; Animation_Change(&this->skelAnime, &gGerudoPurpleWalkingAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGerudoPurpleWalkingAnim), 0, -8.0f); + Animation_GetLastFrame(&gGerudoPurpleWalkingAnim), ANIMMODE_LOOP, -8.0f); this->headRot.y = 0; this->detectedStatus = GERUDO_PURPLE_DETECTION_UNDETECTED; } @@ -602,13 +602,14 @@ void EnGe2_PerformCutsceneActions(EnGe2* this, PlayState* play) { switch (cueId) { case ENGE2_CUEID_BEEHIVE_PATROL: Animation_Change(&this->skelAnime, &gGerudoPurpleLookingAboutAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGerudoPurpleLookingAboutAnim), 0, -8.0f); + Animation_GetLastFrame(&gGerudoPurpleLookingAboutAnim), ANIMMODE_LOOP, -8.0f); EnGe2_GetNextPath(this, play); break; case ENGE2_CUEID_BEEHIVE_RUN_AWAY: Animation_Change(&this->skelAnime, &gGerudoPurpleRunningAwayCutsceneAnim, 1.0f, 0.0f, - Animation_GetLastFrame(&gGerudoPurpleRunningAwayCutsceneAnim), 0, -5.0f); + Animation_GetLastFrame(&gGerudoPurpleRunningAwayCutsceneAnim), ANIMMODE_LOOP, + -5.0f); this->screamTimer = (s32)(Rand_ZeroFloat(10.0f) + 20.0f); break; @@ -617,11 +618,13 @@ void EnGe2_PerformCutsceneActions(EnGe2* this, PlayState* play) { break; case ENGE2_CUEID_GBT_ENTR_STAND_STILL: - Animation_Change(&this->skelAnime, &gGerudoPurpleGreatBayCutsceneAnim, 0.0f, 0.0f, 0.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &gGerudoPurpleGreatBayCutsceneAnim, 0.0f, 0.0f, 0.0f, + ANIMMODE_ONCE, 0.0f); break; case ENGE2_CUEID_GBT_ENTR_BLOWN_AWAY: - Animation_Change(&this->skelAnime, &gGerudoPurpleGreatBayCutsceneAnim, 0.0f, 1.0f, 1.0f, 2, 0.0f); + Animation_Change(&this->skelAnime, &gGerudoPurpleGreatBayCutsceneAnim, 0.0f, 1.0f, 1.0f, + ANIMMODE_ONCE, 0.0f); EnGe2_SetupBlownAwayPath(this, play); this->stateFlags |= GERUDO_PURPLE_STATE_DISABLE_MOVEMENT; this->screamTimer = (s32)(Rand_ZeroFloat(10.0f) + 20.0f); diff --git a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c index e55d0746e..21f207e7c 100644 --- a/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c +++ b/src/overlays/actors/ovl_En_Ge3/z_en_ge3.c @@ -15,7 +15,7 @@ void EnGe3_Destroy(Actor* thisx, PlayState* play); void EnGe3_Update(Actor* thisx, PlayState* play); void EnGe3_Draw(Actor* thisx, PlayState* play); -void EnGe3_ChangeAnim(EnGe3* this, s16 animIndex, u8 mode, f32 morphFrames); +void EnGe3_ChangeAnim(EnGe3* this, s16 animIndex, u8 animMode, f32 morphFrames); void EnGe3_SetupPath(EnGe3* this, PlayState* play); void EnGe3_Idle(EnGe3* this, PlayState* play); void EnGe3_AveilsChamberIdle(EnGe3* this, PlayState* play); @@ -111,7 +111,7 @@ void EnGe3_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->collider); } -void EnGe3_ChangeAnim(EnGe3* this, s16 animIndex, u8 mode, f32 morphFrames) { +void EnGe3_ChangeAnim(EnGe3* this, s16 animIndex, u8 animMode, f32 morphFrames) { static AnimationHeader* sAnimations[GERUDO_AVEIL_ANIM_MAX] = { &gGerudoRedStandAnim, // GERUDO_AVEIL_ANIM_STAND &gGerudoRedWalkAnim, // GERUDO_AVEIL_ANIM_WALK @@ -125,7 +125,7 @@ void EnGe3_ChangeAnim(EnGe3* this, s16 animIndex, u8 mode, f32 morphFrames) { }; Animation_Change(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimations[animIndex]), mode, morphFrames); + Animation_GetLastFrame(sAnimations[animIndex]), animMode, morphFrames); this->animIndex = animIndex; } diff --git a/src/overlays/actors/ovl_En_Geg/z_en_geg.c b/src/overlays/actors/ovl_En_Geg/z_en_geg.c index a01bfbd19..9183856ab 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.c +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.c @@ -7,7 +7,6 @@ #include "z_en_geg.h" #include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#include "objects/object_oF1d_map/object_oF1d_map.h" #include "objects/object_taisou/object_taisou.h" #include "objects/object_hakugin_demo/object_hakugin_demo.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -126,68 +125,112 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -static AnimationInfoS sAnimationInfo[] = { - { &gGoronLyingDownIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &gGoronLyingDownIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &gGoronUnrollAnim, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &gGoronUnrollAnim, 2.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &gGoronUnrollAnim, -2.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &gGoronShiverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &gGoronShiverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &gGoronDropKegAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &gGoronAthleticsSquatSideToSideAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &gGoronAthleticsDoubleArmSideBendAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &gGoronAthleticsShakeLimbsAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &gGoronAthleticsSingleArmSideBendAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &gGoronAthleticsHamstringStretchSittingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &gGoronAthleticsCheerAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &gGoronAthleticsShoutAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &gGoronAthleticsHamstringStretchStandingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &gGoronCoverEarsAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &gGoronSpringLookAroundAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &gGoronSpringLookAroundLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &gGoronShiveringSurprisedAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &gGoronStandingIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +typedef enum { + /* -1 */ ENGEG_ANIM_NONE = -1, + /* 0x00 */ ENGEG_ANIM_0, + /* 0x01 */ ENGEG_ANIM_1, + /* 0x02 */ ENGEG_ANIM_2, + /* 0x03 */ ENGEG_ANIM_3, + /* 0x04 */ ENGEG_ANIM_4, + /* 0x05 */ ENGEG_ANIM_5, + /* 0x06 */ ENGEG_ANIM_6, + /* 0x07 */ ENGEG_ANIM_7, + /* 0x08 */ ENGEG_ANIM_8, + /* 0x09 */ ENGEG_ANIM_9, + /* 0x0A */ ENGEG_ANIM_10, + /* 0x0B */ ENGEG_ANIM_11, + /* 0x0C */ ENGEG_ANIM_12, + /* 0x0D */ ENGEG_ANIM_13, + /* 0x0E */ ENGEG_ANIM_14, + /* 0x0F */ ENGEG_ANIM_15, + /* 0x10 */ ENGEG_ANIM_16, + /* 0x11 */ ENGEG_ANIM_17, + /* 0x12 */ ENGEG_ANIM_18, + /* 0x13 */ ENGEG_ANIM_19, + /* 0x14 */ ENGEG_ANIM_20, + /* 0x15 */ ENGEG_ANIM_MAX +} EnGegAnimation; + +static AnimationInfoS sAnimationInfo[ENGEG_ANIM_MAX] = { + { &gGoronLyingDownIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENGEG_ANIM_0 + { &gGoronLyingDownIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENGEG_ANIM_1 + { &gGoronUnrollAnim, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, // ENGEG_ANIM_2 + { &gGoronUnrollAnim, 2.0f, 0, -1, ANIMMODE_ONCE, -4 }, // ENGEG_ANIM_3 + { &gGoronUnrollAnim, -2.0f, 0, -1, ANIMMODE_ONCE, -4 }, // ENGEG_ANIM_4 + { &gGoronShiverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENGEG_ANIM_5 + { &gGoronShiverAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENGEG_ANIM_6 + { &gGoronDropKegAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, // ENGEG_ANIM_7 + { &gGoronAthleticsSquatSideToSideAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENGEG_ANIM_8 + { &gGoronAthleticsDoubleArmSideBendAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENGEG_ANIM_9 + { &gGoronAthleticsShakeLimbsAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENGEG_ANIM_10 + { &gGoronAthleticsSingleArmSideBendAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENGEG_ANIM_11 + { &gGoronAthleticsHamstringStretchSittingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENGEG_ANIM_12 + { &gGoronAthleticsCheerAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENGEG_ANIM_13 + { &gGoronAthleticsShoutAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENGEG_ANIM_14 + { &gGoronAthleticsHamstringStretchStandingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENGEG_ANIM_15 + { &gGoronCoverEarsAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENGEG_ANIM_16 + { &gGoronSpringLookAroundAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, // ENGEG_ANIM_17 + { &gGoronSpringLookAroundLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENGEG_ANIM_18 + { &gGoronShiveringSurprisedAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, // ENGEG_ANIM_19 + { &gGoronStandingIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENGEG_ANIM_20 }; u16 func_80BB16D0(EnGeg* this) { switch (this->unk_496) { case 0xD5E: return 0xD5F; + case 0xD5F: return 0xD60; + case 0xD60: return 0xD61; + case 0xD62: return 0xD63; + case 0xD64: return 0xD65; + case 0xD66: return 0xD67; + case 0xD67: return 0xD68; + case 0xD68: return 0xD69; + case 0xD6A: return 0xD6B; + case 0xD6B: return 0xD6C; + case 0xD6C: return 0xD6D; + case 0xD6E: return 0xD6F; + case 0xD70: return 0xD71; + case 0xD71: return 0xD72; + case 0xD73: return 0xD74; + case 0xD74: return 0xD75; + case 0xD89: return 0xD8A; + + default: + return 0; } - return 0; } void func_80BB178C(EnGeg* this, PlayState* play) { @@ -372,14 +415,14 @@ s32 func_80BB1D64(EnGeg* this, PlayState* play) { return true; } -void func_80BB1FCC(EnGeg* this, PlayState* play) { +void EnGeg_UpdateSkelAnime(EnGeg* this, PlayState* play) { gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->unk_248].segment); SkelAnime_Update(&this->skelAnime); } -void func_80BB2020(EnGeg* this, PlayState* play) { +void EnGeg_ChangeAnim(EnGeg* this, PlayState* play) { gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[this->unk_248].segment); - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->unk_4AC); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); } s32 func_80BB2088(EnGeg* this, PlayState* play) { @@ -393,7 +436,7 @@ s32 func_80BB2088(EnGeg* this, PlayState* play) { } if (Actor_IsFacingAndNearPlayer(&this->actor, 300.0f, 0x7FF8) && - ((this->unk_4AC == 5) || ((this->unk_4AC == 13) && (this->unk_496 == 0xD69)))) { + ((this->animIndex == ENGEG_ANIM_5) || ((this->animIndex == ENGEG_ANIM_13) && (this->unk_496 == 0xD69)))) { this->unk_230 |= 2; func_80BB1D64(this, play); } else { @@ -412,8 +455,8 @@ s32 func_80BB2088(EnGeg* this, PlayState* play) { void func_80BB217C(EnGeg* this, PlayState* play) { if (Object_IsLoaded(&play->objectCtx, this->unk_248)) { - this->unk_4AC = 5; - func_80BB2020(this, play); + this->animIndex = ENGEG_ANIM_5; + EnGeg_ChangeAnim(this, play); Actor_SetScale(&this->actor, 0.01f); this->unk_230 = 0; this->actor.shape.shadowScale = 20.0f; @@ -509,8 +552,8 @@ void func_80BB2520(EnGeg* this, PlayState* play) { case 0xD66: this->unk_248 = Object_GetIndex(&play->objectCtx, OBJECT_OF1D_MAP); if (this->unk_248 >= 0) { - this->unk_4AC = 19; - func_80BB2020(this, play); + this->animIndex = ENGEG_ANIM_19; + EnGeg_ChangeAnim(this, play); } this->unk_230 |= 0x20; this->actionFunc = func_80BB2944; @@ -527,11 +570,14 @@ void func_80BB2520(EnGeg* this, PlayState* play) { case 0xD8B: this->unk_248 = Object_GetIndex(&play->objectCtx, OBJECT_OF1D_MAP); if (this->unk_248 >= 0) { - this->unk_4AC = 4; - func_80BB2020(this, play); + this->animIndex = ENGEG_ANIM_4; + EnGeg_ChangeAnim(this, play); } this->actionFunc = func_80BB2E00; break; + + default: + break; } } else { if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { @@ -557,6 +603,9 @@ void func_80BB26EC(EnGeg* this, PlayState* play) { this->unk_230 &= ~0x10; this->actionFunc = func_80BB221C; return; + + default: + break; } this->unk_496 = func_80BB16D0(this); @@ -609,12 +658,12 @@ void func_80BB27D4(EnGeg* this, PlayState* play) { void func_80BB2944(EnGeg* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_4AC].animation); + s16 endFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); - if (this->unk_4AC == 19) { - if (curFrame == lastFrame) { - this->unk_4AC = 6; - func_80BB2020(this, play); + if (this->animIndex == ENGEG_ANIM_19) { + if (curFrame == endFrame) { + this->animIndex = ENGEG_ANIM_6; + EnGeg_ChangeAnim(this, play); } } else if ((talkState == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_496 == 0xD67) { @@ -666,8 +715,8 @@ void func_80BB2B1C(EnGeg* this, PlayState* play) { Message_ContinueTextbox(play, this->unk_496); this->unk_248 = Object_GetIndex(&play->objectCtx, OBJECT_TAISOU); if (this->unk_248 >= 0) { - this->unk_4AC = 13; - func_80BB2020(this, play); + this->animIndex = ENGEG_ANIM_13; + EnGeg_ChangeAnim(this, play); } this->actionFunc = func_80BB27D4; } else { @@ -704,21 +753,21 @@ void func_80BB2B1C(EnGeg* this, PlayState* play) { } void func_80BB2E00(EnGeg* this, PlayState* play) { - s16 sp2E = this->skelAnime.curFrame; - s16 sp2C = Animation_GetLastFrame(sAnimationInfo[this->unk_4AC].animation); + s16 curFrame = this->skelAnime.curFrame; + s16 endFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); - if (this->unk_4AC == 2) { + if (this->animIndex == ENGEG_ANIM_2) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if (sp2E == sp2C) { + if (curFrame == endFrame) { CutsceneManager_Stop(this->csId); - this->unk_4AC = 20; - func_80BB2020(this, play); + this->animIndex = ENGEG_ANIM_20; + EnGeg_ChangeAnim(this, play); this->actionFunc = func_80BB30B4; } else if (Animation_OnFrame(&this->skelAnime, 24.0f)) { Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_STAND_IMT); } - } else if (this->unk_4AC == 4) { + } else if (this->animIndex == ENGEG_ANIM_4) { if (Animation_OnFrame(&this->skelAnime, 0.0f)) { this->unk_230 |= 1; this->actor.shape.yOffset = 14.0f; @@ -740,11 +789,11 @@ void func_80BB2F7C(EnGeg* this, PlayState* play) { if ((this->actor.xzDistToPlayer < 150.0f) && (fabsf(this->actor.playerHeightRel) < 10.0f) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { - this->unk_4AC = 2; + this->animIndex = ENGEG_ANIM_2; this->actor.speed = 0.0f; this->unk_230 &= ~1; this->actor.shape.yOffset = 0.0f; - func_80BB2020(this, play); + EnGeg_ChangeAnim(this, play); this->actionFunc = func_80BB2E00; } else { this->actor.speed = 5.0f; @@ -902,7 +951,7 @@ void EnGeg_Update(Actor* thisx, PlayState* play) { EnGeg* this = THIS; this->actionFunc(this, play); - func_80BB1FCC(this, play); + EnGeg_UpdateSkelAnime(this, play); func_80BB2088(this, play); func_80BB1C8C(this); SubS_UpdateFidgetTables(play, this->fidgetTableY, this->fidgetTableZ, ENGEG_FIDGET_TABLE_LEN); diff --git a/src/overlays/actors/ovl_En_Geg/z_en_geg.h b/src/overlays/actors/ovl_En_Geg/z_en_geg.h index 522312fc2..980ada9fd 100644 --- a/src/overlays/actors/ovl_En_Geg/z_en_geg.h +++ b/src/overlays/actors/ovl_En_Geg/z_en_geg.h @@ -2,6 +2,7 @@ #define Z_EN_GEG_H #include "global.h" +#include "objects/object_oF1d_map/object_oF1d_map.h" struct EnGeg; @@ -23,8 +24,8 @@ typedef struct EnGeg { /* 0x242 */ s16 unk_242; /* 0x244 */ s16 unk_244; /* 0x248 */ s32 unk_248; - /* 0x24C */ Vec3s jointTable[18]; - /* 0x2B8 */ Vec3s morphTable[18]; + /* 0x24C */ Vec3s jointTable[GORON_LIMB_MAX]; + /* 0x2B8 */ Vec3s morphTable[GORON_LIMB_MAX]; /* 0x324 */ UNK_TYPE1 unk324[0x144]; /* 0x468 */ s16 unk_468; /* 0x46A */ s16 unk_46A; @@ -38,7 +39,7 @@ typedef struct EnGeg { /* 0x498 */ s16 csId; /* 0x49A */ s16 nextCsId; /* 0x49C */ s16 csIdList[8]; - /* 0x4AC */ s32 unk_4AC; + /* 0x4AC */ s32 animIndex; /* 0x4B0 */ s16 unk_4B0; /* 0x4B4 */ Vec3f unk_4B4; /* 0x4C0 */ Vec3f unk_4C0[2]; diff --git a/src/overlays/actors/ovl_En_Gg/z_en_gg.c b/src/overlays/actors/ovl_En_Gg/z_en_gg.c index ab1f8b539..1d59139a4 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.c +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.c @@ -6,7 +6,6 @@ #include "z_en_gg.h" #include "objects/gameplay_keep/gameplay_keep.h" -#include "objects/object_gg/object_gg.h" #define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_FRIENDLY | ACTOR_FLAG_REACT_TO_LENS) @@ -95,15 +94,44 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static AnimationInfo sAnimationInfo[] = { - { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_00D528, 1.0f, 0.0f, 0.0f, 2, -10.0f }, - { &object_gg_Anim_00D174, 1.0f, 0.0f, 0.0f, 2, -10.0f }, { &object_gg_Anim_00ECC0, 1.0f, 0.0f, 0.0f, 2, -10.0f }, - { &object_gg_Anim_00BAF0, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_00AF40, 1.0f, 0.0f, 0.0f, 0, -10.0f }, - { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_00AF40, 1.0f, 0.0f, 0.0f, 0, -10.0f }, - { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_0100C8, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_gg_Anim_00CDA0, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gg_Anim_00B560, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_gg_Anim_00A4B4, 1.0f, 0.0f, 0.0f, 2, 0.0f }, { &object_gg_Anim_00E86C, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_gg_Anim_00D99C, 1.0f, 0.0f, 0.0f, 2, 0.0f }, { &object_gg_Anim_00E2A4, 1.0f, 0.0f, 0.0f, 0, 0.0f }, +typedef enum { + /* -1 */ ENGG_ANIM_NONE = -1, + /* 0x00 */ ENGG_ANIM_0, + /* 0x01 */ ENGG_ANIM_1, + /* 0x02 */ ENGG_ANIM_2, + /* 0x03 */ ENGG_ANIM_3, + /* 0x04 */ ENGG_ANIM_4, + /* 0x05 */ ENGG_ANIM_5, + /* 0x06 */ ENGG_ANIM_6, + /* 0x07 */ ENGG_ANIM_7, + /* 0x08 */ ENGG_ANIM_8, + /* 0x09 */ ENGG_ANIM_9, + /* 0x0A */ ENGG_ANIM_10, + /* 0x0B */ ENGG_ANIM_11, + /* 0x0C */ ENGG_ANIM_12, + /* 0x0D */ ENGG_ANIM_13, + /* 0x0E */ ENGG_ANIM_14, + /* 0x0F */ ENGG_ANIM_15, + /* 0x10 */ ENGG_ANIM_MAX +} EnGgAnimation; + +static AnimationInfo sAnimationInfo[ENGG_ANIM_MAX] = { + { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -10.0f }, // ENGG_ANIM_0 + { &object_gg_Anim_00D528, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -10.0f }, // ENGG_ANIM_1 + { &object_gg_Anim_00D174, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -10.0f }, // ENGG_ANIM_2 + { &object_gg_Anim_00ECC0, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -10.0f }, // ENGG_ANIM_3 + { &object_gg_Anim_00BAF0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -10.0f }, // ENGG_ANIM_4 + { &object_gg_Anim_00AF40, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -10.0f }, // ENGG_ANIM_5 + { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -10.0f }, // ENGG_ANIM_6 + { &object_gg_Anim_00AF40, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -10.0f }, // ENGG_ANIM_7 + { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -10.0f }, // ENGG_ANIM_8 + { &object_gg_Anim_0100C8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // ENGG_ANIM_9 + { &object_gg_Anim_00CDA0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // ENGG_ANIM_10 + { &object_gg_Anim_00B560, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // ENGG_ANIM_11 + { &object_gg_Anim_00A4B4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, // ENGG_ANIM_12 + { &object_gg_Anim_00E86C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, // ENGG_ANIM_13 + { &object_gg_Anim_00D99C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, // ENGG_ANIM_14 + { &object_gg_Anim_00E2A4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // ENGG_ANIM_15 }; void func_80B34F70(EnGg* this) { @@ -149,7 +177,7 @@ void func_80B35108(EnGg* this, PlayState* play) { } void func_80B351A4(EnGg* this) { - if ((this->unk_2E6 == 2) || (this->unk_2E6 == 3)) { + if ((this->animIndex == ENGG_ANIM_2) || (this->animIndex == ENGG_ANIM_3)) { this->unk_2E2 = 3; } else { s16 temp = this->unk_2E4 - 1; @@ -170,57 +198,57 @@ void func_80B351A4(EnGg* this) { void func_80B35250(EnGg* this) { this->unk_2E4 = 20; this->unk_2E2 = 0; - this->unk_2E6 = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); + this->animIndex = ENGG_ANIM_0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGG_ANIM_0); this->actionFunc = func_80B35450; } void func_80B352A4(EnGg* this, PlayState* play) { - s16 sp26 = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_2E6].animation); + s16 curFrame = this->skelAnime.curFrame; + s16 endFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); - if (sp26 == lastFrame) { + if (curFrame == endFrame) { switch (this->actor.textId) { case 0xCE5: - this->unk_2E6 = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + this->animIndex = ENGG_ANIM_1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGG_ANIM_1); break; case 0xCE6: case 0xCEC: - this->unk_2E6 = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); + this->animIndex = ENGG_ANIM_0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGG_ANIM_0); break; case 0xCE8: - this->unk_2E6 = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + this->animIndex = ENGG_ANIM_2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGG_ANIM_2); break; case 0xCE9: - this->unk_2E6 = 3; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); + this->animIndex = ENGG_ANIM_3; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGG_ANIM_3); break; case 0xCED: case 0xCEE: - this->unk_2E6 = 4; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); + this->animIndex = ENGG_ANIM_4; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGG_ANIM_4); break; default: - this->unk_2E6 = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); + this->animIndex = ENGG_ANIM_0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGG_ANIM_0); break; } SET_WEEKEVENTREG(WEEKEVENTREG_19_80); this->actionFunc = func_80B3556C; - } else if ((this->unk_2E6 == 0) && ((this->actor.textId == 0xCED) || (this->actor.textId == 0xCEE))) { - if (sp26 < (lastFrame - 1)) { + } else if ((this->animIndex == ENGG_ANIM_0) && ((this->actor.textId == 0xCED) || (this->actor.textId == 0xCEE))) { + if (curFrame < (endFrame - 1)) { this->skelAnime.playSpeed = 2.0f; } else { - this->unk_2E6 = 4; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); + this->animIndex = ENGG_ANIM_4; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGG_ANIM_4); } } } @@ -249,7 +277,7 @@ void func_80B35450(EnGg* this, PlayState* play) { void func_80B3556C(EnGg* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { - if (this->unk_2E6 == 4) { + if (this->animIndex == ENGG_ANIM_4) { play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; this->unk_308 = 0; @@ -275,47 +303,43 @@ void func_80B35634(EnGg* this, PlayState* play) { switch (play->csCtx.actorCues[cueChannel]->id) { case 1: - this->unk_2DA = 0; - this->unk_2E6 = 0; + this->csAnimIndex = ENGG_ANIM_0; + this->animIndex = ENGG_ANIM_0; break; case 2: - this->unk_2DA = 9; - this->unk_2E6 = 9; + this->csAnimIndex = ENGG_ANIM_9; + this->animIndex = ENGG_ANIM_9; break; case 3: - this->unk_2DA = 10; - this->unk_2E6 = 10; + this->csAnimIndex = ENGG_ANIM_10; + this->animIndex = ENGG_ANIM_10; break; case 4: - do { - this->unk_344.unk_30 = this->unk_2DA = 11; - } while (0); - this->unk_2E6 = 11; + this->unk_344.animIndex = this->csAnimIndex = ENGG_ANIM_11; + this->animIndex = ENGG_ANIM_11; func_80B364D4(&this->unk_344, play); break; case 5: - do { - this->unk_344.unk_30 = this->unk_2DA = 12; - } while (0); - this->unk_2E6 = 12; + this->unk_344.animIndex = this->csAnimIndex = ENGG_ANIM_12; + //! FAKE: + if (1) {} + this->animIndex = ENGG_ANIM_12; break; case 6: - do { - this->unk_344.unk_30 = this->unk_2DA = 13; - } while (0); - this->unk_2E6 = 13; + this->unk_344.animIndex = this->csAnimIndex = ENGG_ANIM_13; + //! FAKE: + if (1) {} + this->animIndex = ENGG_ANIM_13; break; case 7: - do { - this->unk_344.unk_30 = this->unk_2DA = 14; - } while (0); - this->unk_2E6 = 14; + this->unk_344.animIndex = this->csAnimIndex = ENGG_ANIM_14; + this->animIndex = ENGG_ANIM_14; func_80B364D4(&this->unk_344, play); break; @@ -324,13 +348,13 @@ void func_80B35634(EnGg* this, PlayState* play) { return; default: - this->unk_2DA = 0; + this->csAnimIndex = ENGG_ANIM_0; break; } - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->unk_2DA); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->csAnimIndex); } - if (this->unk_2DA == 14) { + if (this->csAnimIndex == ENGG_ANIM_14) { func_80B358D8(this, play); } @@ -345,16 +369,22 @@ u16 func_80B357F0(EnGg* this) { switch (this->actor.textId) { case 0xCE5: return 0xCE6; + case 0xCE6: return 0xCE8; + case 0xCE8: return 0xCE9; + case 0xCE9: return 0xCEC; + case 0xCEC: return 0xCED; + + default: + return 0; } - return 0; } void func_80B3584C(EnGg* this) { @@ -366,12 +396,12 @@ void func_80B3584C(EnGg* this) { } void func_80B358D8(EnGg* this, PlayState* play) { - s16 sp1E = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_2DA].animation); + s16 curFrame = this->skelAnime.curFrame; + s16 endFrame = Animation_GetLastFrame(sAnimationInfo[this->csAnimIndex].animation); - if ((this->unk_2E6 == 14) && (sp1E == lastFrame)) { - this->unk_2E6 = 15; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 15); + if ((this->animIndex == ENGG_ANIM_14) && (curFrame == endFrame)) { + this->animIndex = ENGG_ANIM_15; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGG_ANIM_15); } } @@ -379,8 +409,8 @@ void func_80B35968(EnGg* this, PlayState* play) { if (this->unk_344.unk_34 != NULL) { this->unk_344.unk_34(&this->unk_344, play); } else { - if ((this->unk_2DA == 11) || (this->unk_2DA == 14)) { - this->unk_344.unk_30 = this->unk_2DA; + if ((this->csAnimIndex == ENGG_ANIM_11) || (this->csAnimIndex == ENGG_ANIM_14)) { + this->unk_344.animIndex = this->csAnimIndex; } func_80B363E8(&this->unk_344, play, &this->unk_320, &this->unk_32C, &this->unk_338); } @@ -433,7 +463,7 @@ void func_80B35B24(EnGgStruct* ptr, PlayState* play) { } void func_80B35B44(EnGgStruct* ptr, PlayState* play) { - if (ptr->unk_30 == 0xE) { + if (ptr->animIndex == ENGG_ANIM_14) { ptr->unk_40++; if (ptr->unk_40 > 0x46) { ptr->unk_48 = 1; @@ -455,13 +485,13 @@ void func_80B35B44(EnGgStruct* ptr, PlayState* play) { ptr->unk_44 = 0x37; } } - } else if ((ptr->unk_30 == 11) || (ptr->unk_30 == 12)) { + } else if ((ptr->animIndex == ENGG_ANIM_11) || (ptr->animIndex == ENGG_ANIM_12)) { ptr->unk_40++; if (ptr->unk_40 > 0x46) { ptr->unk_48 = 1; ptr->unk_40 = 0; } - } else if (ptr->unk_30 == 0xD) { + } else if (ptr->animIndex == ENGG_ANIM_13) { ptr->unk_48 = 0; ptr->unk_40++; if (ptr->unk_40 > 0x46) { @@ -496,7 +526,7 @@ void func_80B35C84(EnGgStruct* ptr, PlayState* play) { sp74 = ptr->unk_40 % temp; ptr->unk_40 = sp74; phi_s7 = 0x46; - } else if (ptr->unk_30 == 0xD) { + } else if (ptr->animIndex == ENGG_ANIM_13) { sp74 = ptr->unk_40; phi_s7 = 0x46; } else { @@ -519,6 +549,7 @@ void func_80B35C84(EnGgStruct* ptr, PlayState* play) { temp_f26 = ptr->unk_00.z + (ptr->unk_18.z * temp_f20) + (0.5f * ptr->unk_24.z * temp_f20 * temp_f20); temp_f20 = Rand_ZeroOne() * 0.003f; + //! FAKE: if (1) {} Matrix_Translate(temp_f22, temp_f24, temp_f26, MTXMODE_NEW); @@ -630,9 +661,9 @@ void func_80B363E8(EnGgStruct* ptr, PlayState* play, Vec3f* arg1, Vec3f* arg2, V ptr->unk_00.x += -4.0f; ptr->unk_0C.x += 4.0f; - if ((ptr->unk_30 == 11) || (ptr->unk_30 == 12) || (ptr->unk_30 == 13)) { + if ((ptr->animIndex == ENGG_ANIM_11) || (ptr->animIndex == ENGG_ANIM_12) || (ptr->animIndex == ENGG_ANIM_13)) { ptr->unk_38 = func_80B35C84; - } else if (ptr->unk_30 == 14) { + } else if (ptr->animIndex == ENGG_ANIM_14) { ptr->unk_38 = func_80B3610C; } } @@ -655,7 +686,7 @@ void EnGg_Init(Actor* thisx, PlayState* play) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); this->actor.bgCheckFlags |= BGCHECKFLAG_PLAYER_400; SkelAnime_InitFlex(play, &this->skelAnime, &object_gg_Skel_00F6C0, &object_gg_Anim_00F578, this->jointTable, - this->morphTable, 20); + this->morphTable, OBJECT_GG_LIMB_MAX); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); @@ -700,11 +731,13 @@ void EnGg_Update(Actor* thisx, PlayState* play) { } if ((play->csCtx.state == CS_STATE_IDLE) && - ((this->unk_2DA != 14) && (this->unk_2DA != 11) && (this->unk_2DA != 12) && (this->unk_2DA != 13))) { + ((this->csAnimIndex != ENGG_ANIM_14) && (this->csAnimIndex != ENGG_ANIM_11) && + (this->csAnimIndex != ENGG_ANIM_12) && (this->csAnimIndex != ENGG_ANIM_13))) { func_80B364D4(&this->unk_344, play); } - if (((this->unk_2DA == 14) || (this->unk_2DA == 11) || (this->unk_2DA == 12) || (this->unk_2DA == 13)) && + if (((this->csAnimIndex == ENGG_ANIM_14) || (this->csAnimIndex == ENGG_ANIM_11) || + (this->csAnimIndex == ENGG_ANIM_12) || (this->csAnimIndex == ENGG_ANIM_13)) && (this->unk_309 == 1)) { func_80B35968(this, play); } @@ -738,7 +771,7 @@ s32 EnGg_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po Gfx** gfx) { EnGg* this = THIS; - if (limbIndex == 2) { + if (limbIndex == OBJECT_GG_LIMB_02) { Matrix_RotateZS(this->unk_2E8, MTXMODE_APPLY); } return false; @@ -750,12 +783,13 @@ void EnGg_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Vec3f sp30 = { 0.0f, 0.0f, 0.0f }; Vec3f sp24 = { 0.0f, 0.0f, 0.0f }; - if (this->unk_2DA == 14) { + if (this->csAnimIndex == ENGG_ANIM_14) { sp30.y = 3.0f; sp30.z = -1.0f; sp24.y = -0.07f; this->unk_309 = 1; - } else if ((this->unk_2DA == 11) || (this->unk_2DA == 12) || (this->unk_2DA == 13)) { + } else if ((this->csAnimIndex == ENGG_ANIM_11) || (this->csAnimIndex == ENGG_ANIM_12) || + (this->csAnimIndex == ENGG_ANIM_13)) { sp30.x = 3.0f; sp24.x = 0.5f; this->unk_309 = 1; @@ -763,7 +797,7 @@ void EnGg_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, this->unk_309 = 0; } - if (limbIndex == 4) { + if (limbIndex == OBJECT_GG_LIMB_04) { Matrix_MultVec3f(&D_80B36DF0, &this->unk_320); Matrix_Push(); Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_NEW); diff --git a/src/overlays/actors/ovl_En_Gg/z_en_gg.h b/src/overlays/actors/ovl_En_Gg/z_en_gg.h index 802024897..436d5a4ab 100644 --- a/src/overlays/actors/ovl_En_Gg/z_en_gg.h +++ b/src/overlays/actors/ovl_En_Gg/z_en_gg.h @@ -2,6 +2,7 @@ #define Z_EN_GG_H #include "global.h" +#include "objects/object_gg/object_gg.h" struct EnGg; struct EnGgStruct; @@ -14,7 +15,7 @@ typedef struct EnGgStruct { /* 0x0C */ Vec3f unk_0C; /* 0x18 */ Vec3f unk_18; /* 0x24 */ Vec3f unk_24; - /* 0x30 */ u8 unk_30; + /* 0x30 */ u8 animIndex; /* 0x34 */ EnGgUnkFunc unk_34; /* 0x38 */ EnGgUnkFunc unk_38; /* 0x3C */ s32 unk_3C; @@ -30,16 +31,16 @@ typedef struct EnGg { /* 0x1D4 */ EnGgActionFunc actionFunc; /* 0x1D8 */ Vec3s unk_1D8; /* 0x1DE */ Vec3s unk_1DE; - /* 0x1E4 */ Vec3s jointTable[20]; - /* 0x25C */ Vec3s morphTable[20]; + /* 0x1E4 */ Vec3s jointTable[OBJECT_GG_LIMB_MAX]; + /* 0x25C */ Vec3s morphTable[OBJECT_GG_LIMB_MAX]; /* 0x2D4 */ UNK_TYPE1 unk_2D4[0x6]; - /* 0x2DA */ u8 unk_2DA; + /* 0x2DA */ u8 csAnimIndex; /* 0x2DB */ u8 cueId; /* 0x2DC */ s16 csId; /* 0x2DE */ UNK_TYPE1 unk2DE[4]; /* 0x2E2 */ s16 unk_2E2; /* 0x2E4 */ s16 unk_2E4; - /* 0x2E6 */ s16 unk_2E6; + /* 0x2E6 */ s16 animIndex; /* 0x2E8 */ s16 unk_2E8; /* 0x2EA */ UNK_TYPE1 unk2EA[0x1A]; /* 0x304 */ s16 unk_304; diff --git a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c index abb80780d..e106c8f88 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.c @@ -5,7 +5,6 @@ */ #include "z_en_gg2.h" -#include "objects/object_gg/object_gg.h" #define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_FRIENDLY | ACTOR_FLAG_REACT_TO_LENS) @@ -39,15 +38,44 @@ ActorInit En_Gg2_InitVars = { (ActorFunc)EnGg2_Draw, }; -AnimationInfo D_80B3BF00[] = { - { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_00D528, 1.0f, 0.0f, 0.0f, 2, -10.0f }, - { &object_gg_Anim_00D174, 1.0f, 0.0f, 0.0f, 2, -10.0f }, { &object_gg_Anim_00ECC0, 1.0f, 0.0f, 0.0f, 2, -10.0f }, - { &object_gg_Anim_00BAF0, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_00AF40, 1.0f, 0.0f, 0.0f, 0, -10.0f }, - { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_00AF40, 1.0f, 0.0f, 0.0f, 0, -10.0f }, - { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, 0, -10.0f }, { &object_gg_Anim_0100C8, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_gg_Anim_00CDA0, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gg_Anim_00B560, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_gg_Anim_00A4B4, 1.0f, 0.0f, 0.0f, 2, 0.0f }, { &object_gg_Anim_00E86C, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_gg_Anim_00D99C, 1.0f, 0.0f, 0.0f, 2, 0.0f }, { &object_gg_Anim_00E2A4, 1.0f, 0.0f, 0.0f, 0, 0.0f }, +typedef enum { + /* -1 */ ENGG2_ANIM_NONE = -1, + /* 0x00 */ ENGG2_ANIM_0, + /* 0x01 */ ENGG2_ANIM_1, + /* 0x02 */ ENGG2_ANIM_2, + /* 0x03 */ ENGG2_ANIM_3, + /* 0x04 */ ENGG2_ANIM_4, + /* 0x05 */ ENGG2_ANIM_5, + /* 0x06 */ ENGG2_ANIM_6, + /* 0x07 */ ENGG2_ANIM_7, + /* 0x08 */ ENGG2_ANIM_8, + /* 0x09 */ ENGG2_ANIM_9, + /* 0x0A */ ENGG2_ANIM_10, + /* 0x0B */ ENGG2_ANIM_11, + /* 0x0C */ ENGG2_ANIM_12, + /* 0x0D */ ENGG2_ANIM_13, + /* 0x0E */ ENGG2_ANIM_14, + /* 0x0F */ ENGG2_ANIM_15, + /* 0x10 */ ENGG2_ANIM_MAX +} EnGg2Animation; + +static AnimationInfo sAnimationInfo[ENGG2_ANIM_MAX] = { + { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -10.0f }, // ENGG2_ANIM_0 + { &object_gg_Anim_00D528, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -10.0f }, // ENGG2_ANIM_1 + { &object_gg_Anim_00D174, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -10.0f }, // ENGG2_ANIM_2 + { &object_gg_Anim_00ECC0, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -10.0f }, // ENGG2_ANIM_3 + { &object_gg_Anim_00BAF0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -10.0f }, // ENGG2_ANIM_4 + { &object_gg_Anim_00AF40, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -10.0f }, // ENGG2_ANIM_5 + { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -10.0f }, // ENGG2_ANIM_6 + { &object_gg_Anim_00AF40, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -10.0f }, // ENGG2_ANIM_7 + { &object_gg_Anim_00F578, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -10.0f }, // ENGG2_ANIM_8 + { &object_gg_Anim_0100C8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // ENGG2_ANIM_9 + { &object_gg_Anim_00CDA0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // ENGG2_ANIM_10 + { &object_gg_Anim_00B560, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // ENGG2_ANIM_11 + { &object_gg_Anim_00A4B4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, // ENGG2_ANIM_12 + { &object_gg_Anim_00E86C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, // ENGG2_ANIM_13 + { &object_gg_Anim_00D99C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, // ENGG2_ANIM_14 + { &object_gg_Anim_00E2A4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // ENGG2_ANIM_15 }; Color_RGBA8 D_80B3C080 = { 255, 255, 255, 255 }; @@ -116,38 +144,38 @@ void func_80B3ADD8(EnGg2* this) { void func_80B3AE60(EnGg2* this, PlayState* play) { s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(D_80B3BF00[this->unk_2EE].animation); + s16 endFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); - if (curFrame == lastFrame) { - switch (this->unk_2EE) { - case 0: - this->unk_2EE = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 1); + if (curFrame == endFrame) { + switch (this->animIndex) { + case ENGG2_ANIM_0: + this->animIndex = ENGG2_ANIM_1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGG2_ANIM_1); this->actionFunc = func_80B3B0A0; break; - case 1: - case 8: - this->unk_2EE = 5; + case ENGG2_ANIM_1: + case ENGG2_ANIM_8: + this->animIndex = ENGG2_ANIM_5; this->actor.flags &= ~ACTOR_FLAG_TARGETABLE; - Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGG2_ANIM_5); this->actionFunc = func_80B3B120; break; - case 5: - this->unk_2EE = 6; - Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); + case ENGG2_ANIM_5: + this->animIndex = ENGG2_ANIM_6; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGG2_ANIM_0); this->actionFunc = func_80B3B21C; break; - case 6: - this->unk_2EE = 7; - Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 5); + case ENGG2_ANIM_6: + this->animIndex = ENGG2_ANIM_7; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGG2_ANIM_5); this->actionFunc = func_80B3B294; break; default: - Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGG2_ANIM_0); this->actionFunc = func_80B3AFB0; break; } @@ -338,7 +366,7 @@ f32 func_80B3B7E4(Path* path, s32 arg1, Vec3f* arg2, Vec3s* arg3) { void func_80B3B8A4(EnGg2* this) { f32 sp1C; - if ((this->unk_2EE != 5) && (this->unk_2EE != 7)) { + if ((this->animIndex != ENGG2_ANIM_5) && (this->animIndex != ENGG2_ANIM_7)) { this->unk_2F2 += 0x62C; sp1C = 1100.0f; } else { @@ -368,7 +396,7 @@ void EnGg2_Init(Actor* thisx, PlayState* play2) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); this->actor.bgCheckFlags |= BGCHECKFLAG_PLAYER_400; SkelAnime_InitFlex(play, &this->skelAnime, &object_gg_Skel_00F6C0, &object_gg_Anim_00F578, this->jointTable, - this->morphTable, 20); + this->morphTable, OBJECT_GG_LIMB_MAX); this->path = SubS_GetPathByIndex(play, ENGG2_GET_PATH_INDEX(&this->actor), ENGG2_PATH_INDEX_NONE); this->actor.flags &= ~ACTOR_FLAG_REACT_TO_LENS; this->unk_2F0 = 0; @@ -384,15 +412,15 @@ void EnGg2_Init(Actor* thisx, PlayState* play2) { CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_04); CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_08); CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_10); - this->unk_2EE = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); + this->animIndex = ENGG2_ANIM_0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGG2_ANIM_0); this->actionFunc = func_80B3AFB0; } else if (play->sceneId == SCENE_17SETUGEN) { if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_04) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_20_08) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_20_10)) { CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_04); - this->unk_2EE = 8; - Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); + this->animIndex = ENGG2_ANIM_8; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGG2_ANIM_0); this->actionFunc = func_80B3B05C; } else { Actor_Kill(&this->actor); @@ -401,8 +429,8 @@ void EnGg2_Init(Actor* thisx, PlayState* play2) { if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_20_04) && CHECK_WEEKEVENTREG(WEEKEVENTREG_20_08) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_20_10)) { CLEAR_WEEKEVENTREG(WEEKEVENTREG_20_08); - this->unk_2EE = 8; - Actor_ChangeAnimationByInfo(&this->skelAnime, D_80B3BF00, 0); + this->animIndex = ENGG2_ANIM_8; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGG2_ANIM_0); this->actionFunc = func_80B3B05C; } else { Actor_Kill(&this->actor); @@ -424,7 +452,7 @@ void EnGg2_Update(Actor* thisx, PlayState* play) { if (play->actorCtx.lensMaskSize == LENS_MASK_ACTIVE_SIZE) { this->actor.flags |= ACTOR_FLAG_REACT_TO_LENS; this->actor.flags |= ACTOR_FLAG_TARGETABLE; - if ((this->unk_2EE == 5) && (this->unk_2EE == 7)) { + if ((this->animIndex == ENGG2_ANIM_5) && (this->animIndex == ENGG2_ANIM_7)) { this->actor.flags &= ~ACTOR_FLAG_TARGETABLE; } } else { @@ -441,7 +469,7 @@ void EnGg2_Update(Actor* thisx, PlayState* play) { func_80B3B8A4(this); Actor_TrackPlayer(play, &this->actor, &this->unk_1E0, &this->unk_1E6, this->actor.focus.pos); - if ((this->unk_2EE == 5) || (this->unk_2EE == 7)) { + if ((this->animIndex == ENGG2_ANIM_5) || (this->animIndex == ENGG2_ANIM_7)) { Actor_PlaySfx_Flagged(&this->actor, NA_SE_EN_SHARP_FLOAT - SFX_FLAG); if ((play->actorCtx.lensMaskSize == LENS_MASK_ACTIVE_SIZE) && ((play->state.frames % 4) == 0)) { func_80B3B4B0(this, play); @@ -454,12 +482,12 @@ void EnGg2_Update(Actor* thisx, PlayState* play) { s32 func_80B3BD44(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnGg2* this = THIS; - if ((this->unk_2EE != 5) && (this->unk_2EE != 7)) { - if (limbIndex == 1) { + if ((this->animIndex != ENGG2_ANIM_5) && (this->animIndex != ENGG2_ANIM_7)) { + if (limbIndex == OBJECT_GG_LIMB_01) { Matrix_RotateYS(this->unk_2F6, MTXMODE_APPLY); } - if (limbIndex == 2) { + if (limbIndex == OBJECT_GG_LIMB_02) { Matrix_RotateZS(this->unk_2F4, MTXMODE_APPLY); } } @@ -469,7 +497,7 @@ s32 func_80B3BD44(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s void func_80B3BDC0(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnGg2* this = THIS; - if (limbIndex == 4) { + if (limbIndex == OBJECT_GG_LIMB_04) { Matrix_MultVec3f(&D_80B3C0A0, &this->unk_304); } } diff --git a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h index 83b4bad42..dd68c20b1 100644 --- a/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h +++ b/src/overlays/actors/ovl_En_Gg2/z_en_gg2.h @@ -2,6 +2,7 @@ #define Z_EN_GG2_H #include "global.h" +#include "objects/object_gg/object_gg.h" struct EnGg2; @@ -20,14 +21,14 @@ typedef struct EnGg2 { /* 0x1DC */ s32 unk_1DC; /* 0x1E0 */ Vec3s unk_1E0; /* 0x1E6 */ Vec3s unk_1E6; - /* 0x1EC */ Vec3s jointTable[20]; - /* 0x264 */ Vec3s morphTable[20]; + /* 0x1EC */ Vec3s jointTable[OBJECT_GG_LIMB_MAX]; + /* 0x264 */ Vec3s morphTable[OBJECT_GG_LIMB_MAX]; /* 0x2DC */ UNK_TYPE1 unk2DC[0x8]; /* 0x2E4 */ s16 csId; /* 0x2E6 */ UNK_TYPE1 unk2E6[4]; /* 0x2EA */ s16 unk_2EA; /* 0x2EC */ s16 unk_2EC; - /* 0x2EE */ s16 unk_2EE; + /* 0x2EE */ s16 animIndex; /* 0x2F0 */ u8 unk_2F0; /* 0x2F1 */ u8 unk_2F1; /* 0x2F2 */ s16 unk_2F2; diff --git a/src/overlays/actors/ovl_En_Giant/z_en_giant.c b/src/overlays/actors/ovl_En_Giant/z_en_giant.c index 8d244c09c..d68e6902f 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.c +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.c @@ -28,10 +28,45 @@ void EnGiant_PerformCutsceneActions(EnGiant* this, PlayState* play); #define GIANT_TYPE_IS_CLOCK_TOWER_FAILURE(type) \ (type >= GIANT_TYPE_MOUNTAIN_CLOCK_TOWER_FAILURE && type <= GIANT_TYPE_OCEAN_CLOCK_TOWER_FAILURE) +/** + * Used as values for cueId. The UNKNOWN ones are never used in-game. + */ +typedef enum { + /* 0 */ GIANT_CUEID_NONE, + /* 1 */ GIANT_CUEID_IDLE, + /* 2 */ GIANT_CUEID_WALKING, + /* 3 */ GIANT_CUEID_LOOKING_UP, + /* 4 */ GIANT_CUEID_RAISING_ARMS, + /* 5 */ GIANT_CUEID_STRUGGLING, + /* 6 */ GIANT_CUEID_FALLING_OVER, + /* 7 */ GIANT_CUEID_IDLE_FADE_IN, + /* 8 */ GIANT_CUEID_TALKING, + /* 9 */ GIANT_CUEID_DONE_TALKING, + /* 10 */ GIANT_CUEID_TEACHING_OATH_TO_ORDER, + /* 11 */ GIANT_CUEID_PLAYER_LEARNED_OATH_TO_ORDER, + /* 12 */ GIANT_CUEID_UNKNOWN_12, + /* 13 */ GIANT_CUEID_UNKNOWN_13, + /* 14 */ GIANT_CUEID_UNKNOWN_14, + /* 15 */ GIANT_CUEID_HOLDING_UP_MOON_IN_CLOCK_TOWER +} GiantCueId; + +ActorInit En_Giant_InitVars = { + ACTOR_EN_GIANT, + ACTORCAT_NPC, + FLAGS, + OBJECT_GIANT, + sizeof(EnGiant), + (ActorFunc)EnGiant_Init, + (ActorFunc)EnGiant_Destroy, + (ActorFunc)EnGiant_Update, + (ActorFunc)EnGiant_Draw, +}; + /** * These values are used to index into sAnimations to pick the appropriate animation. */ typedef enum { + /* -1 */ GIANT_ANIM_NONE = -1, /* 0 */ GIANT_ANIM_LOOK_UP_START, /* 1 */ GIANT_ANIM_LOOK_UP_LOOP, /* 2 */ GIANT_ANIM_FALLING_OVER, @@ -50,49 +85,26 @@ typedef enum { /* 15 */ GIANT_ANIM_MAX } GiantAnimation; -/** - * Used as values for cueId. The UNKNOWN ones are never used in-game. - */ -typedef enum { - /* 0 */ GIANT_CUE_ID_NONE, - /* 1 */ GIANT_CUE_ID_IDLE, - /* 2 */ GIANT_CUE_ID_WALKING, - /* 3 */ GIANT_CUE_ID_LOOKING_UP, - /* 4 */ GIANT_CUE_ID_RAISING_ARMS, - /* 5 */ GIANT_CUE_ID_STRUGGLING, - /* 6 */ GIANT_CUE_ID_FALLING_OVER, - /* 7 */ GIANT_CUE_ID_IDLE_FADE_IN, - /* 8 */ GIANT_CUE_ID_TALKING, - /* 9 */ GIANT_CUE_ID_DONE_TALKING, - /* 10 */ GIANT_CUE_ID_TEACHING_OATH_TO_ORDER, - /* 11 */ GIANT_CUE_ID_PLAYER_LEARNED_OATH_TO_ORDER, - /* 12 */ GIANT_CUE_ID_UNKNOWN_12, - /* 13 */ GIANT_CUE_ID_UNKNOWN_13, - /* 14 */ GIANT_CUE_ID_UNKNOWN_14, - /* 15 */ GIANT_CUE_ID_HOLDING_UP_MOON_IN_CLOCK_TOWER -} GiantCueId; - -ActorInit En_Giant_InitVars = { - ACTOR_EN_GIANT, - ACTORCAT_NPC, - FLAGS, - OBJECT_GIANT, - sizeof(EnGiant), - (ActorFunc)EnGiant_Init, - (ActorFunc)EnGiant_Destroy, - (ActorFunc)EnGiant_Update, - (ActorFunc)EnGiant_Draw, -}; - -static AnimationHeader* sAnimations[] = { - &gGiantLookUpStartAnim, &gGiantLookUpLoopAnim, &gGiantFallingOverAnim, &gGiantRaisedArmsStartAnim, - &gGiantRaisedArmsLoopAnim, &gGiantStruggleStartAnim, &gGiantStruggleLoopAnim, &gGiantIdleAnim, - &gGiantWalkingAnim, &gGiantBigCallStartAnim, &gGiantBigCallLoopAnim, &gGiantBigCallEndAnim, - &gGiantSmallCallStartAnim, &gGiantSmallCallLoopAnim, &gGiantSmallCallEndAnim, +static AnimationHeader* sAnimations[GIANT_ANIM_MAX] = { + &gGiantLookUpStartAnim, // GIANT_ANIM_LOOK_UP_START + &gGiantLookUpLoopAnim, // GIANT_ANIM_LOOK_UP_LOOP + &gGiantFallingOverAnim, // GIANT_ANIM_FALLING_OVER + &gGiantRaisedArmsStartAnim, // GIANT_ANIM_RAISED_ARMS_START + &gGiantRaisedArmsLoopAnim, // GIANT_ANIM_RAISED_ARMS_LOOP + &gGiantStruggleStartAnim, // GIANT_ANIM_STRUGGLE_START + &gGiantStruggleLoopAnim, // GIANT_ANIM_STRUGGLE_LOOP + &gGiantIdleAnim, // GIANT_ANIM_IDLE_LOOP + &gGiantWalkingAnim, // GIANT_ANIM_WALKING_LOOP + &gGiantBigCallStartAnim, // GIANT_ANIM_BIG_CALL_START + &gGiantBigCallLoopAnim, // GIANT_ANIM_BIG_CALL_LOOP + &gGiantBigCallEndAnim, // GIANT_ANIM_BIG_CALL_END + &gGiantSmallCallStartAnim, // GIANT_ANIM_SMALL_CALL_START + &gGiantSmallCallLoopAnim, // GIANT_ANIM_SMALL_CALL_LOOP + &gGiantSmallCallEndAnim, // GIANT_ANIM_SMALL_CALL_END }; void EnGiant_ChangeAnim(EnGiant* this, s16 animIndex) { - if (animIndex >= GIANT_ANIM_LOOK_UP_START && animIndex < GIANT_ANIM_MAX) { + if ((animIndex >= GIANT_ANIM_LOOK_UP_START) && (animIndex < GIANT_ANIM_MAX)) { if (((this->animIndex == GIANT_ANIM_WALKING_LOOP) && (animIndex != GIANT_ANIM_WALKING_LOOP)) || ((animIndex == GIANT_ANIM_WALKING_LOOP) && (this->animIndex != GIANT_ANIM_WALKING_LOOP))) { Animation_Change(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, @@ -160,7 +172,7 @@ void EnGiant_Init(Actor* thisx, PlayState* play) { SkelAnime_InitFlex(play, &this->skelAnime, &gGiantSkel, &gGiantLargeStrideAnim, this->jointTable, this->morphTable, GIANT_LIMB_MAX); EnGiant_ChangeAnim(this, GIANT_ANIM_IDLE_LOOP); - this->cueId = GIANT_CUE_ID_NONE; + this->cueId = GIANT_CUEID_NONE; this->actionFunc = EnGiant_PerformCutsceneActions; this->actor.draw = NULL; this->alpha = 0; @@ -275,58 +287,58 @@ void EnGiant_ChangeToStartOrLoopAnimation(EnGiant* this, s16 requestedAnimIndex) */ void EnGiant_ChangeAnimBasedOnCueId(EnGiant* this) { switch (this->cueId) { - case GIANT_CUE_ID_IDLE: + case GIANT_CUEID_IDLE: EnGiant_ChangeAnim(this, GIANT_ANIM_IDLE_LOOP); break; - case GIANT_CUE_ID_WALKING: + case GIANT_CUEID_WALKING: EnGiant_ChangeAnim(this, GIANT_ANIM_WALKING_LOOP); break; - case GIANT_CUE_ID_STRUGGLING: + case GIANT_CUEID_STRUGGLING: EnGiant_ChangeAnim(this, GIANT_ANIM_STRUGGLE_START); break; - case GIANT_CUE_ID_FALLING_OVER: + case GIANT_CUEID_FALLING_OVER: EnGiant_ChangeAnim(this, GIANT_ANIM_FALLING_OVER); break; - case GIANT_CUE_ID_IDLE_FADE_IN: + case GIANT_CUEID_IDLE_FADE_IN: EnGiant_ChangeAnim(this, GIANT_ANIM_IDLE_LOOP); this->alpha = 0; break; - case GIANT_CUE_ID_TALKING: + case GIANT_CUEID_TALKING: EnGiant_ChangeAnim(this, GIANT_ANIM_BIG_CALL_START); break; - case GIANT_CUE_ID_DONE_TALKING: + case GIANT_CUEID_DONE_TALKING: EnGiant_ChangeAnim(this, GIANT_ANIM_BIG_CALL_END); break; - case GIANT_CUE_ID_TEACHING_OATH_TO_ORDER: + case GIANT_CUEID_TEACHING_OATH_TO_ORDER: EnGiant_ChangeAnim(this, GIANT_ANIM_SMALL_CALL_START); break; - case GIANT_CUE_ID_PLAYER_LEARNED_OATH_TO_ORDER: + case GIANT_CUEID_PLAYER_LEARNED_OATH_TO_ORDER: EnGiant_ChangeAnim(this, GIANT_ANIM_SMALL_CALL_END); break; - case GIANT_CUE_ID_UNKNOWN_12: + case GIANT_CUEID_UNKNOWN_12: EnGiant_ChangeAnim(this, GIANT_ANIM_IDLE_LOOP); break; - case GIANT_CUE_ID_UNKNOWN_13: + case GIANT_CUEID_UNKNOWN_13: EnGiant_ChangeAnim(this, GIANT_ANIM_WALKING_LOOP); break; - case GIANT_CUE_ID_UNKNOWN_14: + case GIANT_CUEID_UNKNOWN_14: if (this->animIndex != GIANT_ANIM_WALKING_LOOP) { EnGiant_ChangeAnim(this, GIANT_ANIM_WALKING_LOOP); } break; - case GIANT_CUE_ID_HOLDING_UP_MOON_IN_CLOCK_TOWER: + case GIANT_CUEID_HOLDING_UP_MOON_IN_CLOCK_TOWER: Animation_Change(&this->skelAnime, &gGiantRaisedArmsStartAnim, 0.0f, Animation_GetLastFrame(&gGiantRaisedArmsStartAnim) - 1.0f, Animation_GetLastFrame(&gGiantRaisedArmsStartAnim), ANIMMODE_ONCE, 0.0f); @@ -339,14 +351,16 @@ void EnGiant_ChangeAnimBasedOnCueId(EnGiant* this) { void EnGiant_UpdateAlpha(EnGiant* this) { switch (this->cueId) { - case GIANT_CUE_ID_FALLING_OVER: + case GIANT_CUEID_FALLING_OVER: if (this->skelAnime.curFrame >= 90.0f && this->alpha > 0) { this->alpha -= 12; } break; - case GIANT_CUE_ID_UNKNOWN_14: + + case GIANT_CUEID_UNKNOWN_14: this->alpha -= 12; break; + default: if (this->alpha < 255) { this->alpha += 8; @@ -363,36 +377,37 @@ void EnGiant_UpdateAlpha(EnGiant* this) { */ void EnGiant_PlayAndUpdateAnimation(EnGiant* this) { if (SkelAnime_Update(&this->skelAnime) && - (this->animIndex != GIANT_ANIM_FALLING_OVER || this->cueId != GIANT_CUE_ID_FALLING_OVER)) { + ((this->animIndex != GIANT_ANIM_FALLING_OVER) || (this->cueId != GIANT_CUEID_FALLING_OVER))) { EnGiant_ChangeAnim(this, this->animIndex); + switch (this->cueId) { - case GIANT_CUE_ID_LOOKING_UP: + case GIANT_CUEID_LOOKING_UP: EnGiant_ChangeToStartOrLoopAnimation(this, GIANT_ANIM_LOOK_UP_START); break; - case GIANT_CUE_ID_RAISING_ARMS: + case GIANT_CUEID_RAISING_ARMS: EnGiant_ChangeToStartOrLoopAnimation(this, GIANT_ANIM_RAISED_ARMS_START); break; - case GIANT_CUE_ID_STRUGGLING: + case GIANT_CUEID_STRUGGLING: EnGiant_ChangeToStartOrLoopAnimation(this, GIANT_ANIM_STRUGGLE_START); break; - case GIANT_CUE_ID_FALLING_OVER: + case GIANT_CUEID_FALLING_OVER: // Unused EnGiant_ChangeToStartOrLoopAnimation(this, GIANT_ANIM_FALLING_OVER); break; - case GIANT_CUE_ID_TALKING: + case GIANT_CUEID_TALKING: EnGiant_ChangeAnim(this, GIANT_ANIM_BIG_CALL_LOOP); break; - case GIANT_CUE_ID_DONE_TALKING: - case GIANT_CUE_ID_PLAYER_LEARNED_OATH_TO_ORDER: + case GIANT_CUEID_DONE_TALKING: + case GIANT_CUEID_PLAYER_LEARNED_OATH_TO_ORDER: EnGiant_ChangeAnim(this, GIANT_ANIM_IDLE_LOOP); break; - case GIANT_CUE_ID_TEACHING_OATH_TO_ORDER: + case GIANT_CUEID_TEACHING_OATH_TO_ORDER: EnGiant_ChangeAnim(this, GIANT_ANIM_SMALL_CALL_LOOP); break; @@ -445,7 +460,7 @@ void EnGiant_PerformClockTowerSuccessActions(EnGiant* this, PlayState* play) { } EnGiant_PlaySound(this); - if (this->cueId == GIANT_CUE_ID_STRUGGLING) { + if (this->cueId == GIANT_CUEID_STRUGGLING) { Actor_PlaySfx_Flagged(&this->actor, NA_SE_IT_KYOJIN_BEARING - SFX_FLAG); } EnGiant_PlayAndUpdateAnimation(this); diff --git a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c index ea3f9fea2..566f35ba0 100644 --- a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c +++ b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.c @@ -5,7 +5,6 @@ */ #include "z_en_ginko_man.h" -#include "objects/object_boj/object_boj.h" #define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_FRIENDLY) @@ -47,15 +46,16 @@ typedef enum { /* 1 */ GINKO_ANIM_SITTING, /* 2 */ GINKO_ANIM_REACHING, /* 3 */ GINKO_ANIM_AMAZED, - /* 4 */ GINKO_ANIM_ADVERTISING + /* 4 */ GINKO_ANIM_ADVERTISING, // looking around for customers + /* 5 */ GINKO_ANIM_MAX } GinkoAnimation; -static AnimationInfo sAnimationInfo[] = { - { &object_boj_Anim_0008C0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - { &object_boj_Anim_0043F0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - { &object_boj_Anim_004F40, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, - { &object_boj_Anim_000AC4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, // looking around for customers - { &object_boj_Anim_004A7C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, +static AnimationInfo sAnimationInfo[GINKO_ANIM_MAX] = { + { &object_boj_Anim_0008C0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, // GINKO_ANIM_LEGSMACKING + { &object_boj_Anim_0043F0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, // GINKO_ANIM_SITTING + { &object_boj_Anim_004F40, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, // GINKO_ANIM_REACHING + { &object_boj_Anim_000AC4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, // GINKO_ANIM_AMAZED + { &object_boj_Anim_004A7C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, // GINKO_ANIM_ADVERTISING }; void EnGinkoMan_Init(Actor* thisx, PlayState* play) { @@ -71,7 +71,7 @@ void EnGinkoMan_Init(Actor* thisx, PlayState* play) { this->choiceDepositWithdrawl = GINKOMAN_CHOICE_RESET; this->serviceFee = 0; SkelAnime_InitFlex(play, &this->skelAnime, &object_boj_Skel_00C240, &object_boj_Anim_0043F0, this->jointTable, - this->morphTable, 16); + this->morphTable, OBJECT_BOJ_LIMB_MAX); EnGinkoMan_SetupIdle(this); } @@ -172,7 +172,7 @@ void EnGinkoMan_DepositDialogue(EnGinkoMan* this, PlayState* play) { SET_WEEKEVENTREG(WEEKEVENTREG_59_40); Message_StartTextbox(play, 0x45B, &this->actor); this->curTextId = 0x45B; - } else if ((HS_GET_BANK_RUPEES() >= 1000) && ((this->previousBankValue) < 1000) && + } else if ((HS_GET_BANK_RUPEES() >= 1000) && (this->previousBankValue < 1000) && !CHECK_WEEKEVENTREG(WEEKEVENTREG_59_80)) { SET_WEEKEVENTREG(WEEKEVENTREG_59_80); Message_StartTextbox(play, 0x45C, &this->actor); @@ -664,16 +664,16 @@ void EnGinkoMan_Update(Actor* thisx, PlayState* play) { s32 EnGinkoMan_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnGinkoMan* this = THIS; - if (limbIndex == 15) { + if (limbIndex == OBJECT_BOJ_LIMB_0F) { *dList = object_boj_DL_00B1D8; } - if (limbIndex == 15) { + if (limbIndex == OBJECT_BOJ_LIMB_0F) { Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); Matrix_RotateXS(this->limb15Rot.y, MTXMODE_APPLY); Matrix_RotateZS(this->limb15Rot.x, MTXMODE_APPLY); Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - } else if (limbIndex == 8) { + } else if (limbIndex == OBJECT_BOJ_LIMB_08) { Matrix_RotateXS(-this->limb8Rot.y, MTXMODE_APPLY); Matrix_RotateZS(-this->limb8Rot.x, MTXMODE_APPLY); } diff --git a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.h b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.h index b8a19d0f3..48ef4bdb1 100644 --- a/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.h +++ b/src/overlays/actors/ovl_En_Ginko_Man/z_en_ginko_man.h @@ -2,6 +2,7 @@ #define Z_EN_GINKO_MAN_H #include "global.h" +#include "objects/object_boj/object_boj.h" struct EnGinkoMan; @@ -11,8 +12,8 @@ typedef struct EnGinkoMan { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ EnGinkoManActionFunc actionFunc; - /* 0x18C */ Vec3s jointTable[0x10]; - /* 0x1EC */ Vec3s morphTable[0x10]; + /* 0x18C */ Vec3s jointTable[OBJECT_BOJ_LIMB_MAX]; + /* 0x1EC */ Vec3s morphTable[OBJECT_BOJ_LIMB_MAX]; /* 0x24C */ Vec3s limb15Rot; /* 0x252 */ Vec3s limb8Rot; /* 0x258 */ s16 curTextId; diff --git a/src/overlays/actors/ovl_En_Gk/z_en_gk.c b/src/overlays/actors/ovl_En_Gk/z_en_gk.c index dd87be400..ad5bc484f 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.c +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.c @@ -5,7 +5,6 @@ */ #include "z_en_gk.h" -#include "objects/object_gk/object_gk.h" #define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_FRIENDLY) @@ -102,14 +101,38 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static AnimationInfo sAnimationInfo[] = { - { &object_gk_Anim_00787C, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gk_Anim_007DC4, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_gk_Anim_0092C0, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gk_Anim_005EDC, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_gk_Anim_009638, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gk_Anim_008774, 1.0f, 0.0f, 0.0f, 0, 0.0f }, - { &object_gk_Anim_00AE34, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gk_Anim_00BD90, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_gk_Anim_00C308, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gk_Anim_009858, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_gk_Anim_009D88, 1.0f, 0.0f, 0.0f, 0, 0.0f }, { &object_gk_Anim_00A21C, 1.0f, 0.0f, 0.0f, 2, 0.0f }, - { &object_gk_Anim_00AAEC, 1.0f, 0.0f, 0.0f, 0, 0.0f }, +typedef enum { + /* -1 */ ENGK_ANIM_NONE = -1, + /* 0x0 */ ENGK_ANIM_0, + /* 0x1 */ ENGK_ANIM_1, + /* 0x2 */ ENGK_ANIM_2, + /* 0x3 */ ENGK_ANIM_3, + /* 0x4 */ ENGK_ANIM_4, + /* 0x5 */ ENGK_ANIM_5, + /* 0x6 */ ENGK_ANIM_6, + /* 0x7 */ ENGK_ANIM_7, + /* 0x8 */ ENGK_ANIM_8, + /* 0x9 */ ENGK_ANIM_9, + /* 0xA */ ENGK_ANIM_10, + /* 0xB */ ENGK_ANIM_11, + /* 0xC */ ENGK_ANIM_12, + /* 0xD */ ENGK_ANIM_MAX +} EnGkAnimation; + +static AnimationInfo sAnimationInfo[ENGK_ANIM_MAX] = { + { &object_gk_Anim_00787C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // ENGK_ANIM_0 + { &object_gk_Anim_007DC4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, // ENGK_ANIM_1 + { &object_gk_Anim_0092C0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // ENGK_ANIM_2 + { &object_gk_Anim_005EDC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // ENGK_ANIM_3 + { &object_gk_Anim_009638, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // ENGK_ANIM_4 + { &object_gk_Anim_008774, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // ENGK_ANIM_5 + { &object_gk_Anim_00AE34, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // ENGK_ANIM_6 + { &object_gk_Anim_00BD90, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, // ENGK_ANIM_7 + { &object_gk_Anim_00C308, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // ENGK_ANIM_8 + { &object_gk_Anim_009858, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, // ENGK_ANIM_9 + { &object_gk_Anim_009D88, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // ENGK_ANIM_10 + { &object_gk_Anim_00A21C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, // ENGK_ANIM_11 + { &object_gk_Anim_00AAEC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // ENGK_ANIM_12 }; Color_RGBA8 D_80B533A0 = { 255, 255, 255, 255 }; @@ -124,18 +147,24 @@ u16 func_80B50410(EnGk* this, PlayState* play) { switch (this->unk_31C) { case 0xE7A: return 0xE7B; + case 0xE7B: return 0xE7C; + case 0xE7C: return 0xE7D; + case 0xE7D: return 0xE7E; + case 0xE7E: return 0xE7F; + case 0xE7F: SET_WEEKEVENTREG(WEEKEVENTREG_40_80); this->unk_1E4 |= 1; return 0xE80; + default: return 0xE7A; } @@ -147,16 +176,21 @@ u16 func_80B50410(EnGk* this, PlayState* play) { switch (this->unk_31C) { case 0xE82: return 0xE83; + case 0xE83: return 0xE7D; + case 0xE7D: return 0xE7E; + case 0xE7E: return 0xE7F; + case 0xE7F: SET_WEEKEVENTREG(WEEKEVENTREG_41_01); this->unk_1E4 |= 1; return 0xE80; + default: return 0xE82; } @@ -197,10 +231,12 @@ u16 func_80B50410(EnGk* this, PlayState* play) { switch (this->unk_31C) { case 0xE85: return 0xE86; + case 0xE86: SET_WEEKEVENTREG(WEEKEVENTREG_41_02); this->unk_1E4 |= 1; return 0xE87; + default: return 0xE85; } @@ -208,9 +244,9 @@ u16 func_80B50410(EnGk* this, PlayState* play) { this->unk_1E4 |= 1; return 0xE87; } - } else { - return 0; } + + return 0; } u16 func_80B50710(EnGk* this) { @@ -229,8 +265,10 @@ u16 func_80B50710(EnGk* this) { this->unk_1E4 |= 0x10; this->unk_1E4 |= 1; return 0xE8C; + + default: + return 0; } - return 0; } void func_80B507A0(EnGk* this, PlayState* play) { @@ -259,8 +297,8 @@ s32 func_80B50854(EnGk* this, PlayState* play) { if ((player->transformation == PLAYER_FORM_GORON) && (play->msgCtx.ocarinaMode == 3) && (play->msgCtx.lastPlayedSong == OCARINA_SONG_GORON_LULLABY)) { Flags_SetSwitch(play, ENGK_GET_3F00(&this->actor)); - this->unk_2E4 = 3; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); + this->animIndex = ENGK_ANIM_3; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGK_ANIM_3); this->actionFunc = func_80B521E8; return true; } @@ -285,12 +323,13 @@ void func_80B509A8(EnGk* this, PlayState* play) { this->unk_30C.y += Rand_ZeroOne(); this->unk_30C.z += 2.0f * Rand_Centered(); - if (this->unk_2E4 == 0) { + if (this->animIndex == ENGK_ANIM_0) { sp4C.x = 0.0f; sp4C.z = 0.0f; sp4C.y = -1.2f; phi_s1 = 25; - } else if ((this->unk_2E4 == 2) || (this->unk_2E4 == 9) || (this->unk_2E4 == 10) || (this->unk_2E4 == 11)) { + } else if ((this->animIndex == ENGK_ANIM_2) || (this->animIndex == ENGK_ANIM_9) || + (this->animIndex == ENGK_ANIM_10) || (this->animIndex == ENGK_ANIM_11)) { sp4C.x = 0.0f; sp4C.z = 0.0f; sp4C.y = -0.5f; @@ -307,28 +346,28 @@ void func_80B50B38(EnGk* this, PlayState* play) { s16 i; s16 temp; - switch (this->unk_2E4) { - case 0: + switch (this->animIndex) { + case ENGK_ANIM_0: this->unk_2E0 = 3; for (i = 0; i < 2; i++) { func_80B509A8(this, play); } break; - case 2: + case ENGK_ANIM_2: this->unk_2E0 = 3; func_80B509A8(this, play); break; - case 1: - case 3: - case 12: + case ENGK_ANIM_1: + case ENGK_ANIM_3: + case ENGK_ANIM_12: this->unk_2E0 = 2; break; - case 9: - case 10: - case 11: + case ENGK_ANIM_9: + case ENGK_ANIM_10: + case ENGK_ANIM_11: this->unk_2E0 = 3; func_80B509A8(this, play); break; @@ -483,22 +522,22 @@ s32 func_80B5123C(EnGk* this, PlayState* play) { } void func_80B51308(EnGk* this, PlayState* play) { - s16 sp1E = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_31A].animation); + s16 curFrame = this->skelAnime.curFrame; + s16 endFrame = Animation_GetLastFrame(sAnimationInfo[this->csAnimIndex].animation); - if ((this->unk_2E4 == 7) && (sp1E == lastFrame)) { - this->unk_2E4 = 8; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 8); + if ((this->animIndex == ENGK_ANIM_7) && (curFrame == endFrame)) { + this->animIndex = ENGK_ANIM_8; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGK_ANIM_8); } } void func_80B51398(EnGk* this, PlayState* play) { - s16 sp1E = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[9].animation); + s16 curFrame = this->skelAnime.curFrame; + s16 endFrame = Animation_GetLastFrame(sAnimationInfo[9].animation); - if ((this->unk_2E4 == 9) && (sp1E == lastFrame)) { - this->unk_2E4 = 10; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 10); + if ((this->animIndex == ENGK_ANIM_9) && (curFrame == endFrame)) { + this->animIndex = ENGK_ANIM_10; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGK_ANIM_10); } } @@ -541,35 +580,35 @@ void func_80B51510(EnGk* this, PlayState* play) { this->cueId = play->csCtx.actorCues[cueChannel]->id; switch (play->csCtx.actorCues[cueChannel]->id) { case 1: - this->unk_31A = 0; - this->unk_2E4 = 0; + this->csAnimIndex = ENGK_ANIM_0; + this->animIndex = ENGK_ANIM_0; break; case 2: - this->unk_31A = 2; - this->unk_2E4 = 2; + this->csAnimIndex = ENGK_ANIM_2; + this->animIndex = ENGK_ANIM_2; break; case 3: - this->unk_31A = 7; - this->unk_2E4 = 7; + this->csAnimIndex = ENGK_ANIM_7; + this->animIndex = ENGK_ANIM_7; break; case 4: - this->unk_31A = 3; - this->unk_2E4 = 3; + this->csAnimIndex = ENGK_ANIM_3; + this->animIndex = ENGK_ANIM_3; break; case 5: - this->unk_31A = 1; - this->unk_2E4 = 1; + this->csAnimIndex = ENGK_ANIM_1; + this->animIndex = ENGK_ANIM_1; this->unk_1E4 |= 0x80; this->actionFunc = func_80B5227C; break; case 6: - this->unk_31A = 12; - this->unk_2E4 = 12; + this->csAnimIndex = ENGK_ANIM_12; + this->animIndex = ENGK_ANIM_12; break; case 7: @@ -579,10 +618,10 @@ void func_80B51510(EnGk* this, PlayState* play) { default: break; } - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->unk_31A); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->csAnimIndex); } - if (this->unk_31A == 7) { + if (this->csAnimIndex == ENGK_ANIM_7) { func_80B51308(this, play); } @@ -594,41 +633,44 @@ void func_80B51510(EnGk* this, PlayState* play) { } void func_80B51698(EnGk* this, PlayState* play) { - s16 sp26 = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_2E4].animation); + s16 curFrame = this->skelAnime.curFrame; + s16 endFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); - if (sp26 == lastFrame) { - switch (this->unk_2E4) { - case 0: - this->unk_2E4 = 2; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + if (curFrame == endFrame) { + switch (this->animIndex) { + case ENGK_ANIM_0: + this->animIndex = ENGK_ANIM_2; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGK_ANIM_2); this->actionFunc = func_80B5216C; break; - case 2: - this->unk_2E4 = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); + case ENGK_ANIM_2: + this->animIndex = ENGK_ANIM_0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGK_ANIM_0); this->actionFunc = func_80B5202C; break; + + default: + break; } } } void func_80B51760(EnGk* this, PlayState* play) { - s16 sp2E = this->skelAnime.curFrame; - s16 lastFrame; + s16 curFrame = this->skelAnime.curFrame; + s16 endFrame; - if (this->unk_2E4 == 11) { - lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_2E4].animation); - if (sp2E == lastFrame) { - this->unk_2E4 = 5; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->unk_2E4); + if (this->animIndex == ENGK_ANIM_11) { + endFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); + if (curFrame == endFrame) { + this->animIndex = ENGK_ANIM_5; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); } - } else if (this->unk_2E4 == 10) { - lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_2E4].animation); - if (sp2E == lastFrame) { - this->unk_2E4 = 11; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->unk_2E4); + } else if (this->animIndex == ENGK_ANIM_10) { + endFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); + if (curFrame == endFrame) { + this->animIndex = ENGK_ANIM_11; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); } } else { if (Flags_GetSwitch(play, ENGK_GET_3F00(&this->actor))) { @@ -643,7 +685,7 @@ void func_80B51760(EnGk* this, PlayState* play) { Message_StartTextbox(play, this->unk_31C, &this->actor); this->actionFunc = func_80B51970; if (this->unk_31C == 0xE81) { - this->unk_2E4 = 0; + this->animIndex = ENGK_ANIM_0; this->unk_1E4 |= 2; } } else if (((this->actor.xzDistToPlayer < 100.0f) || this->actor.isLockedOn) && @@ -673,7 +715,7 @@ void func_80B51970(EnGk* this, PlayState* play) { if (this->unk_1E4 & 1) { this->unk_1E4 &= ~1; this->unk_1E4 &= ~4; - if (this->unk_2E4 == 10) { + if (this->animIndex == ENGK_ANIM_10) { this->unk_1E4 &= ~2; } this->actionFunc = func_80B51760; @@ -691,10 +733,10 @@ void func_80B51970(EnGk* this, PlayState* play) { if (this->unk_1E4 & 2) { Audio_PlaySfx_AtFixedPos(&this->actor.projectedPos, NA_SE_EN_GOLON_KID_CRY - SFX_FLAG); - if (this->unk_2E4 != 10) { - if (this->unk_2E4 != 9) { - this->unk_2E4 = 9; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 9); + if (this->animIndex != ENGK_ANIM_10) { + if (this->animIndex != ENGK_ANIM_9) { + this->animIndex = ENGK_ANIM_9; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGK_ANIM_9); } else { func_80B51398(this, play); } @@ -703,7 +745,7 @@ void func_80B51970(EnGk* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x1000, 0x100); this->actor.world.rot.y = this->actor.shape.rot.y; - if (this->unk_2E4 == 6) { + if (this->animIndex == ENGK_ANIM_6) { func_80B50954(this); } } @@ -717,7 +759,7 @@ void func_80B51B40(EnGk* this, PlayState* play) { this->unk_1E4 &= ~1; this->unk_1E4 &= ~4; - if (this->unk_2E4 == 10) { + if (this->animIndex == ENGK_ANIM_10) { this->unk_1E4 &= ~2; } @@ -752,15 +794,18 @@ void func_80B51B40(EnGk* this, PlayState* play) { this->unk_31C = 0xE8A; Message_StartTextbox(play, this->unk_31C, &this->actor); break; + + default: + break; } } if (this->unk_1E4 & 2) { Audio_PlaySfx_AtFixedPos(&this->actor.projectedPos, NA_SE_EN_GOLON_KID_CRY - SFX_FLAG); - if (this->unk_2E4 != 10) { - if (this->unk_2E4 != 9) { - this->unk_2E4 = 9; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 9); + if (this->animIndex != ENGK_ANIM_10) { + if (this->animIndex != ENGK_ANIM_9) { + this->animIndex = ENGK_ANIM_9; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGK_ANIM_9); } else { func_80B51398(this, play); } @@ -778,8 +823,8 @@ void func_80B51D9C(EnGk* this, PlayState* play) { CutsceneManager_StartWithPlayerCsAndSetFlag(this->csId, &this->actor); if (this->unk_1E4 & 4) { this->unk_1E4 &= ~4; - this->unk_2E4 = 6; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 6); + this->animIndex = ENGK_ANIM_6; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGK_ANIM_6); this->actionFunc = func_80B51EA4; } else { this->unk_1E4 |= 4; @@ -880,21 +925,21 @@ void func_80B5216C(EnGk* this, PlayState* play) { } void func_80B521E8(EnGk* this, PlayState* play) { - s16 sp1E = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_2E4].animation); + s16 curFrame = this->skelAnime.curFrame; + s16 endFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); - if (sp1E == lastFrame) { - this->unk_2E4 = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + if (curFrame == endFrame) { + this->animIndex = ENGK_ANIM_1; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGK_ANIM_1); this->actionFunc = func_80B5227C; } } void func_80B5227C(EnGk* this, PlayState* play) { - s16 sp26 = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_2E4].animation); + s16 curFrame = this->skelAnime.curFrame; + s16 endFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); - if ((sp26 + 1) == lastFrame) { + if (curFrame == (endFrame - 1)) { func_800B14D4(play, 20.0f, &this->actor.home.pos); this->unk_350 = 60; if (!(this->unk_1E4 & 0x80)) { @@ -948,6 +993,9 @@ void func_80B52430(EnGk* this, PlayState* play) { this->unk_1E4 &= ~4; this->actionFunc = func_80B51760; return; + + default: + break; } } @@ -1005,7 +1053,7 @@ void EnGk_Init(Actor* thisx, PlayState* play) { EnGk* this = THIS; SkelAnime_InitFlex(play, &this->skelAnime, &object_gk_Skel_0079C0, &object_gk_Anim_00787C, this->jointTable, - this->morphTable, 20); + this->morphTable, OBJECT_GK_LIMB_MAX); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); @@ -1019,16 +1067,16 @@ void EnGk_Init(Actor* thisx, PlayState* play) { this->actor.gravity = -1.0f; if (ENGK_GET_F(&this->actor) == ENGK_F_1) { - this->unk_2E4 = 5; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 5); + this->animIndex = ENGK_ANIM_5; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGK_ANIM_5); if (play->sceneId == SCENE_17SETUGEN2) { if (Flags_GetSwitch(play, ENGK_GET_3F00(&this->actor))) { Actor_Kill(&this->actor); - } else { - this->csId = this->actor.csId; - this->path = SubS_GetPathByIndex(play, ENGK_GET_PATH_INDEX(&this->actor), ENGK_PATH_INDEX_NONE); - this->actionFunc = func_80B51760; + return; } + this->csId = this->actor.csId; + this->path = SubS_GetPathByIndex(play, ENGK_GET_PATH_INDEX(&this->actor), ENGK_PATH_INDEX_NONE); + this->actionFunc = func_80B51760; } else if (play->sceneId == SCENE_GORONRACE) { if (CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_SNOWHEAD_TEMPLE)) { if (gSaveContext.save.entrance == ENTRANCE(GORON_RACETRACK, 1)) { @@ -1054,11 +1102,11 @@ void EnGk_Init(Actor* thisx, PlayState* play) { Actor_Kill(&this->actor); } } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_CALMED_GORON_ELDERS_SON)) { - this->unk_2E4 = 0; + this->animIndex = ENGK_ANIM_0; this->csId = this->actor.csId; this->actor.flags |= ACTOR_FLAG_10; this->actor.flags |= ACTOR_FLAG_2000000; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENGK_ANIM_0); this->actionFunc = func_80B5202C; } else { this->actionFunc = func_80B52654; @@ -1111,7 +1159,7 @@ void EnGk_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, sp28.x = 1100.0f; sp28.z = -500.0f; - if (this->unk_2E4 == 0) { + if (this->animIndex == ENGK_ANIM_0) { sp34.y = -100.0f; sp28.y = -100.0f; @@ -1121,7 +1169,8 @@ void EnGk_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, sp4C = sp40; sp4C.x *= -1.0f; - } else if ((this->unk_2E4 == 2) || (this->unk_2E4 == 9) || (this->unk_2E4 == 10) || (this->unk_2E4 == 11)) { + } else if ((this->animIndex == ENGK_ANIM_2) || (this->animIndex == ENGK_ANIM_9) || + (this->animIndex == ENGK_ANIM_10) || (this->animIndex == ENGK_ANIM_11)) { sp34.y = 400.0f; sp28.y = 400.0f; @@ -1133,7 +1182,7 @@ void EnGk_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, sp4C.x *= -1.0f; } - if (limbIndex == 17) { + if (limbIndex == OBJECT_GK_LIMB_11) { if (ENGK_GET_F(&this->actor) == ENGK_F_1) { phi_f0 = 100.0f; } else { @@ -1164,7 +1213,7 @@ void EnGk_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { s32 phi_v1; switch (limbIndex) { - case 18: + case OBJECT_GK_LIMB_12: if (this->unk_1E4 & 8) { phi_v1 = true; } else { @@ -1191,7 +1240,7 @@ void EnGk_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { Matrix_Push(); break; - case 9: + case OBJECT_GK_LIMB_09: if (this->unk_1E4 & 8) { phi_v1 = true; } else { @@ -1216,6 +1265,9 @@ void EnGk_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { Matrix_Push(); break; + + default: + break; } } @@ -1260,8 +1312,9 @@ void EnGk_Draw(Actor* thisx, PlayState* play) { if (ENGK_GET_F(&this->actor) != ENGK_F_2) { Gfx_SetupDL25_Xlu(play->state.gfxCtx); - if ((this->unk_2E4 == 0) || (this->unk_2E4 == 1) || (this->unk_2E4 == 2) || (this->unk_2E4 == 3) || - (this->unk_2E4 == 4)) { + if ((this->animIndex == ENGK_ANIM_0) || (this->animIndex == ENGK_ANIM_1) || + (this->animIndex == ENGK_ANIM_2) || (this->animIndex == ENGK_ANIM_3) || + (this->animIndex == ENGK_ANIM_4)) { pos.x = this->actor.world.pos.x - 15.0f; pos.y = this->actor.world.pos.y; pos.z = this->actor.world.pos.z; diff --git a/src/overlays/actors/ovl_En_Gk/z_en_gk.h b/src/overlays/actors/ovl_En_Gk/z_en_gk.h index 130b97675..6bd28ad94 100644 --- a/src/overlays/actors/ovl_En_Gk/z_en_gk.h +++ b/src/overlays/actors/ovl_En_Gk/z_en_gk.h @@ -2,6 +2,7 @@ #define Z_EN_GK_H #include "global.h" +#include "objects/object_gk/object_gk.h" struct EnGk; @@ -32,17 +33,17 @@ typedef struct EnGk { /* 0x1E4 */ u16 unk_1E4; /* 0x1E8 */ Path* path; /* 0x1EC */ s32 unk_1EC; - /* 0x1F0 */ Vec3s jointTable[20]; - /* 0x1F0 */ Vec3s morphTable[20]; + /* 0x1F0 */ Vec3s jointTable[OBJECT_GK_LIMB_MAX]; + /* 0x1F0 */ Vec3s morphTable[OBJECT_GK_LIMB_MAX]; /* 0x2E0 */ s16 unk_2E0; /* 0x2E2 */ s16 unk_2E2; - /* 0x2E4 */ s16 unk_2E4; + /* 0x2E4 */ s16 animIndex; /* 0x2E8 */ Vec3f unk_2E8; /* 0x2F4 */ Vec3f unk_2F4; /* 0x300 */ Vec3f unk_300; /* 0x30C */ Vec3f unk_30C; /* 0x318 */ s16 csId; - /* 0x31A */ u8 unk_31A; + /* 0x31A */ u8 csAnimIndex; /* 0x31B */ u8 cueId; /* 0x31C */ u16 unk_31C; /* 0x31E */ s16 unk_31E; diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.c b/src/overlays/actors/ovl_En_Gm/z_en_gm.c index 787ce43b9..39b705649 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -6,7 +6,6 @@ #include "z_en_gm.h" #include "overlays/actors/ovl_En_Door/z_en_door.h" -#include "objects/object_in2/object_in2.h" #define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_FRIENDLY | ACTOR_FLAG_10) @@ -209,20 +208,38 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static AnimationInfoS sAnimationInfo[] = { - { &object_in2_Anim_009CDC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_in2_Anim_009CDC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_in2_Anim_00A5E0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_in2_Anim_00A70C, 1.0f, 0, 1, ANIMMODE_LOOP, 0 }, - { &object_in2_Anim_008090, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_in2_Anim_00898C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_in2_Anim_009450, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_in2_Anim_00AD18, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_in2_Anim_00AD18, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_in2_Anim_00B8B0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_in2_Anim_00BA80, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_in2_Anim_00C03C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_in2_Anim_00B990, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, +typedef enum { + /* -1 */ ENGM_ANIM_NONE = -1, + /* 0x0 */ ENGM_ANIM_0, + /* 0x1 */ ENGM_ANIM_1, + /* 0x2 */ ENGM_ANIM_2, + /* 0x3 */ ENGM_ANIM_3, + /* 0x4 */ ENGM_ANIM_4, + /* 0x5 */ ENGM_ANIM_5, + /* 0x6 */ ENGM_ANIM_6, + /* 0x7 */ ENGM_ANIM_7, + /* 0x8 */ ENGM_ANIM_8, + /* 0x9 */ ENGM_ANIM_9, + /* 0xA */ ENGM_ANIM_10, + /* 0xB */ ENGM_ANIM_11, + /* 0xC */ ENGM_ANIM_12, + /* 0xD */ ENGM_ANIM_MAX +} EnGmAnimation; + +static AnimationInfoS sAnimationInfo[ENGM_ANIM_MAX] = { + { &object_in2_Anim_009CDC, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENGM_ANIM_0 + { &object_in2_Anim_009CDC, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENGM_ANIM_1 + { &object_in2_Anim_00A5E0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENGM_ANIM_2 + { &object_in2_Anim_00A70C, 1.0f, 0, 1, ANIMMODE_LOOP, 0 }, // ENGM_ANIM_3 + { &object_in2_Anim_008090, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENGM_ANIM_4 + { &object_in2_Anim_00898C, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, // ENGM_ANIM_5 + { &object_in2_Anim_009450, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, // ENGM_ANIM_6 + { &object_in2_Anim_00AD18, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENGM_ANIM_7 + { &object_in2_Anim_00AD18, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENGM_ANIM_8 + { &object_in2_Anim_00B8B0, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, // ENGM_ANIM_9 + { &object_in2_Anim_00BA80, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENGM_ANIM_10 + { &object_in2_Anim_00C03C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENGM_ANIM_11 + { &object_in2_Anim_00B990, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENGM_ANIM_12 }; Actor* func_8094DEE0(EnGm* this, PlayState* play, u8 arg2, s16 arg3) { @@ -286,43 +303,43 @@ EnDoor* func_8094DF90(PlayState* play, s32 arg1) { return SubS_FindDoor(play, phi_a1); } -s32 func_8094DFF8(EnGm* this, PlayState* play) { - s32 ret = false; +s32 EnGm_UpdateSkelAnime(EnGm* this, PlayState* play) { + s32 isAnimFinished = false; if (this->unk_262 < 0) { return false; } if (this->unk_262 >= 0) { - this->skelAnime.playSpeed = this->unk_3A8; - ret = SkelAnime_Update(&this->skelAnime); + this->skelAnime.playSpeed = this->animPlaySpeed; + isAnimFinished = SkelAnime_Update(&this->skelAnime); } - return ret; + return isAnimFinished; } -s32 func_8094E054(EnGm* this, PlayState* play, s32 arg2) { +s32 EnGm_ChangeAnim(EnGm* this, PlayState* play, s32 animIndex) { s8 tmp = this->unk_262; - s32 phi_v1 = false; - s32 ret = false; + s32 changeAnim = false; + s32 didAnimChange = false; - if ((arg2 == 0) || (arg2 == 1)) { - if ((this->unk_3E8 != 0) && (this->unk_3E8 != 1)) { - phi_v1 = true; + if ((animIndex == ENGM_ANIM_0) || (animIndex == ENGM_ANIM_1)) { + if ((this->animIndex != ENGM_ANIM_0) && (this->animIndex != ENGM_ANIM_1)) { + changeAnim = true; } - } else if (arg2 != this->unk_3E8) { - phi_v1 = true; + } else if (this->animIndex != animIndex) { + changeAnim = true; } - if (phi_v1) { + if (changeAnim) { if (tmp >= 0) { - this->unk_3E8 = arg2; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, arg2); - this->unk_3A8 = this->skelAnime.playSpeed; + this->animIndex = animIndex; + didAnimChange = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, animIndex); + this->animPlaySpeed = this->skelAnime.playSpeed; } } - return ret; + return didAnimChange; } s32 func_8094E0F8(EnGm* this, PlayState* play) { @@ -486,6 +503,9 @@ s32 func_8094E52C(EnGm* this, PlayState* play) { this->unk_3E0++; ret = true; break; + + default: + break; } return ret; @@ -502,7 +522,7 @@ s32 func_8094E69C(EnGm* this, PlayState* play) { switch (this->unk_3E0) { case 0: Actor_PlaySfx(&this->actor, NA_SE_EV_CHAIR_ROLL); - func_8094E054(this, play, 2); + EnGm_ChangeAnim(this, play, ENGM_ANIM_2); this->unk_3E2 = 0; this->unk_3E0++; break; @@ -558,6 +578,7 @@ s32 func_8094E69C(EnGm* this, PlayState* play) { this->unk_3E2 = 0; this->unk_3E0++; break; + case 9: sp48 = this->actor.world.rot.y; this->unk_3E2++; @@ -565,13 +586,16 @@ s32 func_8094E69C(EnGm* this, PlayState* play) { Math_ApproachS(&this->actor.shape.rot.y, sp48, 3, 0x2AA8); this->unk_3A4 &= ~0x20; } else { - func_8094E054(this, play, 1); + EnGm_ChangeAnim(this, play, ENGM_ANIM_1); this->actor.shape.rot.y = sp48; this->unk_3E0++; this->unk_3E2 = 0; ret = true; } break; + + default: + break; } return ret; } @@ -639,7 +663,7 @@ s32 func_8094EB1C(EnGm* this, PlayState* play) { break; } Actor_PlaySfx(&this->actor, NA_SE_EV_CHAIR_ROLL); - func_8094E054(this, play, 2); + EnGm_ChangeAnim(this, play, ENGM_ANIM_2); this->unk_3E2 = 0; this->unk_3E0++; @@ -669,7 +693,7 @@ s32 func_8094EB1C(EnGm* this, PlayState* play) { Math_ApproachS(&this->actor.shape.rot.y, oldYaw, 3, 0x2AA8); this->unk_3A4 &= ~0x20; } else { - func_8094E054(this, play, 1); + EnGm_ChangeAnim(this, play, ENGM_ANIM_1); this->actor.shape.rot.y = oldYaw; this->unk_3E2 = 0; this->unk_3E0++; @@ -763,7 +787,7 @@ s32 func_8094EFC4(EnGm* this, PlayState* play) { if (play->csCtx.state != CS_STATE_IDLE) { if (this->unk_3F8 == 0) { if ((play->sceneId == SCENE_MILK_BAR) && (gSaveContext.sceneLayer == 2)) { - func_8094E054(this, play, 0); + EnGm_ChangeAnim(this, play, ENGM_ANIM_0); this->unk_258 = 255; } this->cueId = 255; @@ -879,9 +903,9 @@ void func_8094F3D0(EnGm* this, PlayState* play) { } s32 func_8094F4EC(EnGm* this, PlayState* play) { - if ((this->unk_258 != 6) && (this->unk_3E8 == 12)) { + if ((this->unk_258 != 6) && (this->animIndex == ENGM_ANIM_12)) { this->unk_3A4 &= ~0x2000; - func_8094E054(this, play, 8); + EnGm_ChangeAnim(this, play, ENGM_ANIM_8); } return true; } @@ -897,30 +921,30 @@ s32 func_8094F53C(EnGm* this, PlayState* play) { if (this->unk_3A6 != sp32) { switch (sp32) { case 0x2B13: - func_8094E054(this, play, 2); + EnGm_ChangeAnim(this, play, ENGM_ANIM_2); break; case 0x2B14: case 0x2B18: - func_8094E054(this, play, 0); + EnGm_ChangeAnim(this, play, ENGM_ANIM_0); break; case 0x2B16: - func_8094E054(this, play, 1); + EnGm_ChangeAnim(this, play, ENGM_ANIM_1); break; case 0x2B15: - func_8094E054(this, play, 5); + EnGm_ChangeAnim(this, play, ENGM_ANIM_5); break; case 0x2B17: - func_8094E054(this, play, 6); + EnGm_ChangeAnim(this, play, ENGM_ANIM_6); break; default: - if ((this->unk_3E8 == 7) || (this->unk_3E8 == 8)) { + if ((this->animIndex == ENGM_ANIM_7) || (this->animIndex == ENGM_ANIM_8)) { this->unk_3A4 |= 0x2000; - func_8094E054(this, play, 12); + EnGm_ChangeAnim(this, play, ENGM_ANIM_12); } break; } @@ -941,6 +965,9 @@ s32 func_8094F53C(EnGm* this, PlayState* play) { this->unk_268 = toto; } break; + + default: + break; } if (sp32 == 0x2AA8) { @@ -963,7 +990,7 @@ s32 func_8094F53C(EnGm* this, PlayState* play) { this->unk_18C(this, play); } - if ((this->unk_3E8 == 6) && !(play->actorCtx.flags & ACTORCTX_FLAG_5) && + if ((this->animIndex == ENGM_ANIM_6) && !(play->actorCtx.flags & ACTORCTX_FLAG_5) && Animation_OnFrame(&this->skelAnime, 20.0f)) { Actor_PlaySfx(&this->actor, NA_SE_EV_HANKO); } @@ -1039,7 +1066,7 @@ s32 func_8094F904(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { this->actor.flags &= ~ACTOR_FLAG_TARGETABLE; this->unk_3A4 |= 0x100; this->unk_3A4 |= 0x200; - func_8094E054(this, play, 7); + EnGm_ChangeAnim(this, play, ENGM_ANIM_7); this->actor.gravity = 0.0f; ret = true; } @@ -1087,7 +1114,7 @@ s32 func_8094FAC4(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { SubS_SetOfferMode(&this->unk_3A4, SUBS_OFFER_MODE_ONSCREEN, SUBS_OFFER_MODE_MASK); this->unk_3A4 |= 0x100; this->unk_3A4 |= 0x200; - func_8094E054(this, play, 7); + EnGm_ChangeAnim(this, play, ENGM_ANIM_7); this->actor.gravity = -1.0f; ret = true; } @@ -1102,9 +1129,9 @@ s32 func_8094FCC4(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { if (this->unk_258 == 0) { Math_Vec3f_Copy(&this->actor.world.pos, &D_80951D90); SubS_SetOfferMode(&this->unk_3A4, SUBS_OFFER_MODE_ONSCREEN, SUBS_OFFER_MODE_MASK); - func_8094E054(this, play, 0); + EnGm_ChangeAnim(this, play, ENGM_ANIM_0); } else { - func_8094E054(this, play, 9); + EnGm_ChangeAnim(this, play, ENGM_ANIM_9); this->skelAnime.moveFlags = ANIM_FLAG_NOMOVE; } this->unk_3A4 |= 0x100; @@ -1118,7 +1145,7 @@ s32 func_8094FD88(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 ret = false; if (func_8094F7D0(this, play, scheduleOutput, ACTORCAT_NPC, ACTOR_EN_RECEPGIRL)) { - func_8094E054(this, play, 11); + EnGm_ChangeAnim(this, play, ENGM_ANIM_11); SubS_SetOfferMode(&this->unk_3A4, SUBS_OFFER_MODE_ONSCREEN, SUBS_OFFER_MODE_MASK); this->unk_3A4 |= 0x100; this->unk_3A4 |= 0x200; @@ -1134,7 +1161,7 @@ s32 func_8094FE10(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { al = func_8094DEE0(this, play, ACTORCAT_NPC, ACTOR_EN_AL); if (func_8094F7D0(this, play, scheduleOutput, ACTORCAT_NPC, ACTOR_EN_TOTO) && (al != NULL) && (al->update != NULL)) { - func_8094E054(this, play, 11); + EnGm_ChangeAnim(this, play, ENGM_ANIM_11); SubS_SetOfferMode(&this->unk_3A4, SUBS_OFFER_MODE_ONSCREEN, SUBS_OFFER_MODE_MASK); this->unk_268 = al; if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_86_20)) { @@ -1176,11 +1203,11 @@ s32 func_8094FF04(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { this->unk_3C8 = 4; this->unk_3CA = 4; this->unk_3CC = 8; - func_8094E054(this, play, 0); + EnGm_ChangeAnim(this, play, ENGM_ANIM_0); func_8094E278(play); } else { Math_Vec3f_Copy(&this->actor.world.pos, &sp30); - func_8094E054(this, play, 9); + EnGm_ChangeAnim(this, play, ENGM_ANIM_9); this->skelAnime.moveFlags = ANIM_FLAG_NOMOVE; } this->unk_400 = 0; @@ -1202,7 +1229,7 @@ s32 func_80950088(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { SubS_SetOfferMode(&this->unk_3A4, SUBS_OFFER_MODE_ONSCREEN, SUBS_OFFER_MODE_MASK); this->unk_3A4 |= (0x2000 | 0x100); this->unk_3A4 |= 0x200; - func_8094E054(this, play, 12); + EnGm_ChangeAnim(this, play, ENGM_ANIM_12); return true; } @@ -1217,7 +1244,7 @@ s32 func_80950120(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { SubS_SetOfferMode(&this->unk_3A4, SUBS_OFFER_MODE_ONSCREEN, SUBS_OFFER_MODE_MASK); this->unk_3A4 |= (0x800 | 0x100); this->unk_3A4 |= 0x200; - func_8094E054(this, play, 4); + EnGm_ChangeAnim(this, play, ENGM_ANIM_4); return true; } @@ -1238,7 +1265,7 @@ s32 func_809501B8(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { this->unk_3CC = 8; this->actor.targetMode = TARGET_MODE_6; this->unk_3B4 = 60.0f; - func_8094E054(this, play, 10); + EnGm_ChangeAnim(this, play, ENGM_ANIM_10); return true; } @@ -1334,11 +1361,11 @@ s32 func_80950388(EnGm* this, PlayState* play) { s32 func_809503F8(EnGm* this, PlayState* play) { s32 pad; - if (this->unk_3E8 == 9) { + if (this->animIndex == ENGM_ANIM_9) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; SubS_SetOfferMode(&this->unk_3A4, SUBS_OFFER_MODE_ONSCREEN, SUBS_OFFER_MODE_MASK); - func_8094E054(this, play, 0); + EnGm_ChangeAnim(this, play, ENGM_ANIM_0); } else { AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } @@ -1348,7 +1375,8 @@ s32 func_809503F8(EnGm* this, PlayState* play) { s32 func_80950490(EnGm* this, PlayState* play) { static s32 D_80951DE4[] = { - 1, 5, 5, 1, 6, 5, 1, 5, 6, 1, 5, 6, + ENGM_ANIM_1, ENGM_ANIM_5, ENGM_ANIM_5, ENGM_ANIM_1, ENGM_ANIM_6, ENGM_ANIM_5, + ENGM_ANIM_1, ENGM_ANIM_5, ENGM_ANIM_6, ENGM_ANIM_1, ENGM_ANIM_5, ENGM_ANIM_6, }; s32 pad; @@ -1358,32 +1386,32 @@ s32 func_80950490(EnGm* this, PlayState* play) { this->unk_3CA = 1; this->unk_3CC = 8; this->unk_400 = 1; - func_8094E054(this, play, 3); + EnGm_ChangeAnim(this, play, ENGM_ANIM_3); } return false; } this->unk_400 = 0; - switch (this->unk_3E8) { - case 9: + switch (this->animIndex) { + case ENGM_ANIM_9: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; SubS_SetOfferMode(&this->unk_3A4, SUBS_OFFER_MODE_ONSCREEN, SUBS_OFFER_MODE_MASK); this->unk_3C8 = 4; this->unk_3CA = 4; this->unk_3CC = 8; - func_8094E054(this, play, 0); + EnGm_ChangeAnim(this, play, ENGM_ANIM_0); func_8094E278(play); } else { AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); } break; - case 5: - case 6: + case ENGM_ANIM_5: + case ENGM_ANIM_6: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_8094E054(this, play, D_80951DE4[this->unk_3F4]); + EnGm_ChangeAnim(this, play, D_80951DE4[this->unk_3F4]); this->unk_3F4++; this->unk_3F4 %= 12; this->unk_3DE = Rand_S16Offset(30, 30); @@ -1392,7 +1420,7 @@ s32 func_80950490(EnGm* this, PlayState* play) { default: if (DECR(this->unk_3DE) == 0) { - func_8094E054(this, play, D_80951DE4[this->unk_3F4]); + EnGm_ChangeAnim(this, play, D_80951DE4[this->unk_3F4]); this->unk_3F4++; this->unk_3F4 %= 12; this->unk_3DE = Rand_S16Offset(30, 30); @@ -1433,6 +1461,7 @@ s32 func_80950690(EnGm* this, PlayState* play) { break; case 8: + default: break; } @@ -1574,6 +1603,9 @@ void func_80950C24(EnGm* this, PlayState* play) { case 30: func_8095097C(this, play); break; + + default: + break; } Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); @@ -1629,7 +1661,7 @@ void func_80950DB8(EnGm* this, PlayState* play) { } void func_80950F2C(EnGm* this, PlayState* play) { - s32 sp50[] = { 0, 0, 3, 2 }; + s32 csAnimIndex[] = { ENGM_ANIM_0, ENGM_ANIM_0, ENGM_ANIM_3, ENGM_ANIM_2 }; Player* player = GET_PLAYER(play); s32 pad; Vec3f sp3C; @@ -1644,7 +1676,7 @@ void func_80950F2C(EnGm* this, PlayState* play) { Actor_PlaySfx(&this->actor, NA_SE_EV_CHAIR_ROLL); } this->cueId = cueId; - func_8094E054(this, play, sp50[cueId]); + EnGm_ChangeAnim(this, play, csAnimIndex[cueId]); } if ((this->cueId == 3) && (this->unk_268 != NULL) && (this->unk_268->update != NULL)) { @@ -1670,9 +1702,10 @@ void EnGm_Init(Actor* thisx, PlayState* play) { } ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 22.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &object_in2_Skel_0078B0, NULL, this->jointTable, this->morphTable, 20); - this->unk_3E8 = -1; - func_8094E054(this, play, 0); + SkelAnime_InitFlex(play, &this->skelAnime, &object_in2_Skel_0078B0, NULL, this->jointTable, this->morphTable, + OBJECT_IN2_LIMB_MAX); + this->animIndex = ENGM_ANIM_NONE; + EnGm_ChangeAnim(this, play, ENGM_ANIM_0); Collider_InitAndSetCylinder(play, &this->colliderCylinder, &this->actor, &sCylinderInit); Collider_InitAndSetSphere(play, &this->colliderSphere, &this->actor, &sSphereInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); @@ -1698,7 +1731,7 @@ void EnGm_Update(Actor* thisx, PlayState* play) { if (!func_8094E0F8(this, play)) { if (!func_8094EE84(this, play) && func_8094EFC4(this, play)) { func_80950F2C(this, play); - func_8094DFF8(this, play); + EnGm_UpdateSkelAnime(this, play); func_8094E2D0(this); return; } @@ -1708,7 +1741,7 @@ void EnGm_Update(Actor* thisx, PlayState* play) { func_8094F53C(this, play); if (this->unk_258 != 0) { - func_8094DFF8(this, play); + EnGm_UpdateSkelAnime(this, play); func_8094E2D0(this); func_8094F2E8(this); SubS_Offer(&this->actor, play, this->unk_3B4, 30.0f, PLAYER_IA_NONE, this->unk_3A4 & SUBS_OFFER_MODE_MASK); @@ -1726,20 +1759,20 @@ s32 EnGm_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po EnGm* this = THIS; s32 fidgetIndex; - if (limbIndex == 16) { + if (limbIndex == OBJECT_IN2_LIMB_10) { func_8094F3D0(this, play); } switch (limbIndex) { - case 9: + case OBJECT_IN2_LIMB_09: fidgetIndex = 0; break; - case 10: + case OBJECT_IN2_LIMB_0A: fidgetIndex = 1; break; - case 13: + case OBJECT_IN2_LIMB_0D: fidgetIndex = 2; break; @@ -1763,20 +1796,20 @@ void EnGm_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Vec3f sp30; s32 pad2; - if ((CutsceneManager_GetCurrentCsId() == CS_ID_NONE) && (limbIndex == 16)) { + if ((CutsceneManager_GetCurrentCsId() == CS_ID_NONE) && (limbIndex == OBJECT_IN2_LIMB_10)) { Matrix_MultVec3f(&D_80951E24, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); } OPEN_DISPS(play->state.gfxCtx); - if ((limbIndex == 15) && (this->unk_3A4 & 0x800)) { + if ((limbIndex == OBJECT_IN2_LIMB_0F) && (this->unk_3A4 & 0x800)) { gSPDisplayList(POLY_OPA_DISP++, object_in2_DL_007528); } CLOSE_DISPS(play->state.gfxCtx); - if (limbIndex == 9) { + if (limbIndex == OBJECT_IN2_LIMB_09) { Matrix_MultVec3f(&gZeroVec3f, &sp30); Math_Vec3f_ToVec3s(&this->colliderSphere.dim.worldSphere.center, &sp30); } @@ -1799,7 +1832,7 @@ void EnGm_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { overrideRot = false; } - if (limbIndex == 16) { + if (limbIndex == OBJECT_IN2_LIMB_10) { SubS_UpdateLimb(BINANG_ADD(this->unk_3BC + this->unk_3C0, 0x4000), BINANG_ADD(this->unk_3BE + this->unk_3C2 + this->actor.shape.rot.y, 0x4000), &this->unk_290, &this->unk_2A8, stepRot, overrideRot); @@ -1810,7 +1843,7 @@ void EnGm_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { Matrix_RotateXS(this->unk_2A8.x, MTXMODE_APPLY); Matrix_RotateZS(this->unk_2A8.z, MTXMODE_APPLY); Matrix_Push(); - } else if (limbIndex == 9) { + } else if (limbIndex == OBJECT_IN2_LIMB_09) { SubS_UpdateLimb(BINANG_ADD(this->unk_3C0, 0x4000), BINANG_ADD(this->unk_3C2 + this->actor.shape.rot.y, 0x4000), &this->unk_29C, &this->unk_2AE, stepRot, overrideRot); Matrix_Pop(); @@ -1824,8 +1857,10 @@ void EnGm_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { } void EnGm_Draw(Actor* thisx, PlayState* play) { - static TexturePtr D_80951E30[] = { object_in2_Tex_0054A8, object_in2_Tex_005028, object_in2_Tex_006828, - object_in2_Tex_005028, object_in2_Tex_005CE8, object_in2_Tex_006C68 }; + static TexturePtr D_80951E30[] = { + object_in2_Tex_0054A8, object_in2_Tex_005028, object_in2_Tex_006828, + object_in2_Tex_005028, object_in2_Tex_005CE8, object_in2_Tex_006C68, + }; EnGm* this = THIS; if ((this->unk_258 != 0) && (this->unk_262 >= 0)) { diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.h b/src/overlays/actors/ovl_En_Gm/z_en_gm.h index 572fa322f..968d6dd07 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.h +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.h @@ -2,6 +2,7 @@ #define Z_EN_GM_H #include "global.h" +#include "objects/object_in2/object_in2.h" struct EnGm; @@ -42,11 +43,11 @@ typedef struct EnGm { /* 0x29C */ Vec3f unk_29C; /* 0x2A8 */ Vec3s unk_2A8; /* 0x2AE */ Vec3s unk_2AE; - /* 0x2B4 */ Vec3s jointTable[20]; - /* 0x32C */ Vec3s morphTable[20]; + /* 0x2B4 */ Vec3s jointTable[OBJECT_IN2_LIMB_MAX]; + /* 0x32C */ Vec3s morphTable[OBJECT_IN2_LIMB_MAX]; /* 0x3A4 */ u16 unk_3A4; /* 0x3A6 */ u16 unk_3A6; - /* 0x3A8 */ f32 unk_3A8; + /* 0x3A8 */ f32 animPlaySpeed; /* 0x3AC */ f32 unk_3AC; /* 0x3B0 */ f32 unk_3B0; /* 0x3B4 */ f32 unk_3B4; @@ -69,7 +70,7 @@ typedef struct EnGm { /* 0x3E0 */ s16 unk_3E0; /* 0x3E2 */ s16 unk_3E2; /* 0x3E4 */ EnGmUnkFunc unk_3E4; - /* 0x3E8 */ s32 unk_3E8; + /* 0x3E8 */ s32 animIndex; /* 0x3EC */ UNK_TYPE1 unk3EC[0x4]; /* 0x3F0 */ s32 prevTalkState; /* 0x3F4 */ s32 unk_3F4; diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.c b/src/overlays/actors/ovl_En_Go/z_en_go.c index 10dda353c..f5678eedd 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -82,8 +82,8 @@ typedef enum EnGoEffectType { /* 7 */ ENGO_EFFECT_STEAM = ENGO_EFFECT_STEAM_MIN } EnGoEffectType; -typedef enum EnGoAnimationIndex { - /* -1 */ ENGO_ANIM_INVALID = -1, +typedef enum EnGoAnimation { + /* -1 */ ENGO_ANIM_NONE = -1, /* 0 */ ENGO_ANIM_GORON_MIN, /* 0 */ ENGO_ANIM_LYINGDOWNIDLE = ENGO_ANIM_GORON_MIN, /* 1 */ ENGO_ANIM_LYINGDOWNIDLE_IMM, @@ -95,21 +95,21 @@ typedef enum EnGoAnimationIndex { /* 7 */ ENGO_ANIM_DROPKEG, /* 8 */ ENGO_ANIM_COVEREARS, /* 9 */ ENGO_ANIM_SHIVERINGSURPRISED, - /* 10 */ ENGO_ANIM_ATHLETICS_MIN, - /* 10 */ ENGO_ANIM_DOUBLE_ARM_SIDEBEND = ENGO_ANIM_ATHLETICS_MIN, - /* 11 */ ENGO_ANIM_SQUAT_SIDE_TO_SIDE, - /* 12 */ ENGO_ANIM_SHAKE_LIMBS, - /* 13 */ ENGO_ANIM_SINGLE_ARM_SIDEBEND, - /* 14 */ ENGO_ANIM_SITTING_STRETCH, - /* 15 */ ENGO_ANIM_CHEER, - /* 16 */ ENGO_ANIM_SHOUT, - /* 17 */ ENGO_ANIM_HELP_SITTING_STRETCH, - /* 18 */ ENGO_ANIM_SPRING_MIN, - /* 18 */ ENGO_ANIM_SHOW = ENGO_ANIM_SPRING_MIN, - /* 19 */ ENGO_ANIM_SHOW_LOOPED, - /* 20 */ ENGO_ANIM_LOOK_AROUND, - /* 21 */ ENGO_ANIM_LOOK_AROUND_LOOPED -} EnGoAnimationIndex; + /* 10 */ ENGO_ANIM_ATHLETICS_MIN, + /* 10 */ ENGO_ANIM_DOUBLE_ARM_SIDEBEND = ENGO_ANIM_ATHLETICS_MIN, + /* 11 */ ENGO_ANIM_SQUAT_SIDE_TO_SIDE, + /* 12 */ ENGO_ANIM_SHAKE_LIMBS, + /* 13 */ ENGO_ANIM_SINGLE_ARM_SIDEBEND, + /* 14 */ ENGO_ANIM_SITTING_STRETCH, + /* 15 */ ENGO_ANIM_CHEER, + /* 16 */ ENGO_ANIM_SHOUT, + /* 17 */ ENGO_ANIM_HELP_SITTING_STRETCH, + /* 18 */ ENGO_ANIM_SPRING_MIN, + /* 18 */ ENGO_ANIM_SHOW = ENGO_ANIM_SPRING_MIN, + /* 19 */ ENGO_ANIM_SHOW_LOOPED, + /* 20 */ ENGO_ANIM_LOOK_AROUND, + /* 21 */ ENGO_ANIM_LOOK_AROUND_LOOPED +} EnGoAnimation; void EnGo_Idle(EnGo* this, PlayState* play); void EnGo_Sleep(EnGo* this, PlayState* play); @@ -309,7 +309,7 @@ static DamageTable sDamageTable = { /** * Animations used in the actor. * - * @see EnGoAnimationIndex + * @see EnGoAnimation */ static AnimationInfoS sAnimationInfo[] = { @@ -530,7 +530,7 @@ void EnGo_DrawDust(EnGoEffect effect[ENGO_EFFECT_COUNT], PlayState* play2) { * @param pos Position around which the effects appear */ void EnGo_InitSnow(EnGoEffect effect[ENGO_SNOW_EFFECT_COUNT], Vec3f pos) { - static u8 effectIndexToSnowEffectTable[ENGO_SNOW_EFFECT_COUNT] = { + static u8 sEffectIndexToSnowEffectTable[ENGO_SNOW_EFFECT_COUNT] = { ENGO_EFFECT_SNOW3, ENGO_EFFECT_SNOW1, ENGO_EFFECT_SNOW1, ENGO_EFFECT_SNOW2, ENGO_EFFECT_SNOW3, ENGO_EFFECT_SNOW1, ENGO_EFFECT_SNOW1, ENGO_EFFECT_SNOW2, ENGO_EFFECT_SNOW3, ENGO_EFFECT_SNOW1, ENGO_EFFECT_SNOW1, ENGO_EFFECT_SNOW2, @@ -570,7 +570,7 @@ void EnGo_InitSnow(EnGoEffect effect[ENGO_SNOW_EFFECT_COUNT], Vec3f pos) { effect->alphaDenom = effect->alphaNumer = 1; // Assign a snow effect value of 'ENGO_EFFECT_SNOW1'/'2'/'3' - effect->type = effectIndexToSnowEffectTable[i]; + effect->type = sEffectIndexToSnowEffectTable[i]; // Initialize the parameters for the paired element randRelativeToWorldPos.x = ((Rand_ZeroOne() - 0.5f) * 80.0f) + effect->pos.x; @@ -977,27 +977,27 @@ s32 EnGo_UpdateSpringArrivalCutscene(EnGo* this, PlayState* play) { * * @return True if non-repeating animation has finished */ -s32 EnGo_UpdateAnimationToCurrent(EnGo* this, PlayState* play) { +s32 EnGo_UpdateSkelAnime(EnGo* this, PlayState* play) { s8 objIndex = this->actor.objBankIndex; s8 extraObjIndex = -1; - s32 ret = false; + s32 isAnimFinished = false; - if ((this->curAnimIndex >= ENGO_ANIM_SPRING_MIN) && (this->hakuginDemoObjIndex >= 0)) { + if ((this->animIndex >= ENGO_ANIM_SPRING_MIN) && (this->hakuginDemoObjIndex >= 0)) { extraObjIndex = this->hakuginDemoObjIndex; - } else if ((this->curAnimIndex >= ENGO_ANIM_ATHLETICS_MIN) && (this->taisouObjIndex >= 0)) { + } else if ((this->animIndex >= ENGO_ANIM_ATHLETICS_MIN) && (this->taisouObjIndex >= 0)) { extraObjIndex = this->taisouObjIndex; - } else if (this->curAnimIndex < ENGO_ANIM_ATHLETICS_MIN) { + } else if (this->animIndex < ENGO_ANIM_ATHLETICS_MIN) { extraObjIndex = this->actor.objBankIndex; } if (extraObjIndex >= 0) { gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[extraObjIndex].segment); - this->skelAnime.playSpeed = this->curAnimPlaySpeed; - ret = SkelAnime_Update(&this->skelAnime); + this->skelAnime.playSpeed = this->animPlaySpeed; + isAnimFinished = SkelAnime_Update(&this->skelAnime); gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objIndex].segment); } - return ret; + return isAnimFinished; } /** @@ -1005,7 +1005,7 @@ s32 EnGo_UpdateAnimationToCurrent(EnGo* this, PlayState* play) { */ s32 EnGo_UpdateSfx(EnGo* this, PlayState* play) { if (play->csCtx.state == CS_STATE_IDLE) { - if (this->curAnimIndex == ENGO_ANIM_ROLL) { + if (this->animIndex == ENGO_ANIM_ROLL) { if (Animation_OnFrame(&this->skelAnime, 2.0f)) { Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_CIRCLE); } @@ -1013,7 +1013,7 @@ s32 EnGo_UpdateSfx(EnGo* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 22.0f)) { Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_SIT_IMT); } - } else if ((this->curAnimIndex == ENGO_ANIM_UNROLL) || (this->curAnimIndex == ENGO_ANIM_UNROLL_IMM)) { + } else if ((this->animIndex == ENGO_ANIM_UNROLL) || (this->animIndex == ENGO_ANIM_UNROLL_IMM)) { if (Animation_OnFrame(&this->skelAnime, 2.0f)) { Actor_PlaySfx(&this->actor, NA_SE_EN_GOLON_CIRCLE_OFF); } @@ -1037,10 +1037,10 @@ s32 EnGo_UpdateSfx(EnGo* this, PlayState* play) { * * @return True if animation was changed */ -s32 EnGo_ChangeAnim(EnGo* this, PlayState* play, EnGoAnimationIndex animIndex) { +s32 EnGo_ChangeAnim(EnGo* this, PlayState* play, EnGoAnimation animIndex) { s8 objIndex = this->actor.objBankIndex; s8 extraObjIndex = -1; - s32 ret = false; + s32 didAnimChange = false; if ((animIndex >= ENGO_ANIM_SPRING_MIN) && (this->hakuginDemoObjIndex >= 0)) { extraObjIndex = this->hakuginDemoObjIndex; @@ -1052,13 +1052,13 @@ s32 EnGo_ChangeAnim(EnGo* this, PlayState* play, EnGoAnimationIndex animIndex) { if (extraObjIndex >= 0) { gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[extraObjIndex].segment); - this->curAnimIndex = animIndex; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, animIndex); - this->curAnimPlaySpeed = this->skelAnime.playSpeed; + this->animIndex = animIndex; + didAnimChange = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, animIndex); + this->animPlaySpeed = this->skelAnime.playSpeed; gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[objIndex].segment); } - return ret; + return didAnimChange; } /** @@ -1651,7 +1651,7 @@ void EnGo_ChangeToStretchingAnimation(EnGo* this, PlayState* play) { EnGo_ChangeAnim(this, play, sSubtypeToAnimIndex[subtypeLookup]); // Move the sitting Goron forward, since their spawn location is the same as their standing counterpart. - if (this->curAnimIndex == ENGO_ANIM_SITTING_STRETCH) { + if (this->animIndex == ENGO_ANIM_SITTING_STRETCH) { Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.shape.rot.y, &sStretchingGoronOffset, &newSittingStretcherPos); @@ -1701,7 +1701,7 @@ void EnGo_ChangeToSpectatingAnimation(EnGo* this, PlayState* play) { void EnGo_ChangeToFrozenAnimation(EnGo* this, PlayState* play) { Collider_InitAndSetCylinder(play, &this->colliderCylinder, &this->actor, &sCylinderInitFrozen); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - this->curAnimIndex = -1; + this->animIndex = ENGO_ANIM_NONE; EnGo_ChangeAnim(this, play, ENGO_ANIM_SHIVER); this->sleepState = ENGO_AWAKE; this->iceBlockScale = (this->scaleFactor / 0.01f) * 0.9f; @@ -1899,7 +1899,7 @@ void EnGo_SetupInitialAction(EnGo* this, PlayState* play) { SkelAnime_InitFlex(play, &this->skelAnime, &gGoronSkel, NULL, this->jointTable, this->morphTable, GORON_LIMB_MAX); - this->curAnimIndex = ENGO_ANIM_INVALID; + this->animIndex = ENGO_ANIM_NONE; EnGo_ChangeAnim(this, play, ENGO_ANIM_UNROLL); this->actor.draw = EnGo_Draw; @@ -2168,14 +2168,14 @@ void EnGo_HandleSpringArrivalCutscene(EnGo* this, PlayState* play) { switch (this->springArrivalCueId) { case 3: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && - (this->curAnimIndex == ENGO_ANIM_LOOK_AROUND)) { + (this->animIndex == ENGO_ANIM_LOOK_AROUND)) { EnGo_ChangeAnim(this, play, ENGO_ANIM_LOOK_AROUND_LOOPED); } break; case 4: if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame) && - (this->curAnimIndex == ENGO_ANIM_SHOW)) { + (this->animIndex == ENGO_ANIM_SHOW)) { EnGo_ChangeAnim(this, play, ENGO_ANIM_SHOW_LOOPED); } break; @@ -2439,7 +2439,7 @@ void EnGo_Update(Actor* thisx, PlayState* play) { if (!(this->actionFlags & ENGO_FLAG_FROZEN)) { EnGo_UpdateEyes(this); - EnGo_UpdateAnimationToCurrent(this, play); + EnGo_UpdateSkelAnime(this, play); EnGo_UpdateAttentionTargetAndReactions(this, play); EnGo_UpdateSfx(this, play); } @@ -2599,7 +2599,7 @@ void EnGo_Draw(Actor* thisx, PlayState* play) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeTexIndex])); - if (this->curAnimIndex == ENGO_ANIM_SITTING_STRETCH) { + if (this->animIndex == ENGO_ANIM_SITTING_STRETCH) { Matrix_Translate(0.0f, 0.0f, -4000.0f, MTXMODE_APPLY); } SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.h b/src/overlays/actors/ovl_En_Go/z_en_go.h index 0ada7fe1e..97959a03e 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.h +++ b/src/overlays/actors/ovl_En_Go/z_en_go.h @@ -106,7 +106,7 @@ typedef struct EnGo { /* 0x390 */ u16 actionFlags; /* 0x392 */ u16 lastTextId; /* 0x394 */ u8 springArrivalCueId; - /* 0x398 */ f32 curAnimPlaySpeed; + /* 0x398 */ f32 animPlaySpeed; /* 0x39C */ f32 iceBlockScale; /* 0x3A0 */ f32 iceBlockAlpha; /* 0x3A4 */ f32 scaleFactor; @@ -132,7 +132,7 @@ typedef struct EnGo { /* 0x3CE */ s16 fidgetTableY[ENGO_FIDGET_TABLE_LEN]; /* 0x3D4 */ s16 surprisePhase; /* 0x3D8 */ MsgEventFunc msgEventFunc; - /* 0x3DC */ s32 curAnimIndex; + /* 0x3DC */ s32 animIndex; /* 0x3E0 */ UNK_TYPE1 unk3E0[0x4]; /* 0x3E4 */ s32 indexPathPoint; /* 0x3E8 */ s32 indexEffect; diff --git a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c index 148b2d116..aa6eb041f 100644 --- a/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -674,6 +674,7 @@ void func_80940090(EnGoroiwa* this, PlayState* play) { sp10C.x = this->actor.world.pos.x; sp10C.y = this->actor.world.pos.y + this->unk_1DC; sp10C.z = this->actor.world.pos.z; + //! FAKE: if (1) {} spD8 = spEC * 150.0f; spA8 = 0x10000 / spD8; @@ -1117,8 +1118,8 @@ void func_809419D0(EnGoroiwa* this) { void func_80941A10(EnGoroiwa* this, PlayState* play) { static EnGoroiwaUnkFunc D_80942E94[] = { - &func_8093F498, - &func_8093F34C, + func_8093F498, + func_8093F34C, }; static u16 D_80942E9C[][2] = { { NA_SE_EV_BIGBALL_ROLL - SFX_FLAG, NA_SE_EV_BIGBALL_ROLL_SR - SFX_FLAG }, @@ -1507,6 +1508,9 @@ void EnGoroiwa_Update(Actor* thisx, PlayState* play) { this->actor.floorBgId = 50; } break; + + default: + break; } func_8093FAA4(this, play); diff --git a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c index 3c0d97d20..90b39f860 100644 --- a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c +++ b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.c @@ -75,8 +75,9 @@ typedef enum { /* 4 */ DRAGONFLY_ANIM_HOVER, /* 5 */ DRAGONFLY_ANIM_DAMAGE, /* 6 */ DRAGONFLY_ANIM_DEAD, - /* 7 */ DRAGONFLY_ANIM_FALL -} EnGrasshopperAnim; + /* 7 */ DRAGONFLY_ANIM_FALL, + /* 8 */ DRAGONFLY_ANIM_MAX +} DragonflyAnimation; static s32 sOccupiedIndices[] = { false, false, false, false, false, @@ -333,7 +334,7 @@ void EnGrasshopper_Destroy(Actor* thisx, PlayState* play) { sOccupiedIndices[this->index] = false; } -static AnimationHeader* sAnimations[] = { +static AnimationHeader* sAnimations[DRAGONFLY_ANIM_MAX] = { &gDragonflyRaiseTailAnim, // DRAGONFLY_ANIM_RAISE_TAIL &gDragonflyLowerTailAnim, // DRAGONFLY_ANIM_LOWER_TAIL &gDragonflyFlyAnim, // DRAGONFLY_ANIM_FLY @@ -344,7 +345,7 @@ static AnimationHeader* sAnimations[] = { &gDragonflyFallAnim, // DRAGONFLY_ANIM_FALL }; -static u8 sAnimationModes[] = { +static u8 sAnimationModes[DRAGONFLY_ANIM_MAX] = { ANIMMODE_ONCE, // DRAGONFLY_ANIM_RAISE_TAIL ANIMMODE_ONCE, // DRAGONFLY_ANIM_LOWER_TAIL ANIMMODE_LOOP, // DRAGONFLY_ANIM_FLY @@ -358,15 +359,15 @@ static u8 sAnimationModes[] = { void EnGrasshopper_ChangeAnim(EnGrasshopper* this, s32 animIndex) { f32 morphFrames; - this->endFrame = Animation_GetLastFrame(sAnimations[animIndex]); + this->animEndFrame = Animation_GetLastFrame(sAnimations[animIndex]); morphFrames = 0.0f; if ((animIndex == DRAGONFLY_ANIM_ATTACK) || (animIndex == DRAGONFLY_ANIM_HOVER) || (animIndex == DRAGONFLY_ANIM_DAMAGE)) { morphFrames = -3.0f; } - Animation_Change(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, this->endFrame, sAnimationModes[animIndex], - morphFrames); + Animation_Change(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, this->animEndFrame, + sAnimationModes[animIndex], morphFrames); } void EnGrasshopper_RaiseTail(EnGrasshopper* this) { @@ -389,7 +390,7 @@ void EnGrasshopper_LowerTail(EnGrasshopper* this) { void EnGrasshopper_DecideAction(EnGrasshopper* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; - if (curFrame >= this->endFrame) { + if (curFrame >= this->animEndFrame) { if (this->decision == DRAGONFLY_DECISION_ATTACK) { EnGrasshopper_SetupAttack(this); } else { @@ -580,6 +581,9 @@ void EnGrasshopper_Bank(EnGrasshopper* this, PlayState* play) { this->actionFunc = EnGrasshopper_RoamInCircles; } break; + + default: + break; } } @@ -735,7 +739,7 @@ void EnGrasshopper_Attack(EnGrasshopper* this, PlayState* play) { Math_ApproachF(&this->actor.world.pos.y, this->targetApproachPos.y, 0.1f, this->approachSpeed); Math_ApproachF(&this->approachSpeed, 10.0f, 0.1f, 1.0f); Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xA, 0xFA0, 0xA); - if (curFrame >= this->endFrame) { + if (curFrame >= this->animEndFrame) { EnGrasshopper_SetupWaitAfterAttack(this); } } @@ -831,7 +835,7 @@ void EnGrasshopper_Dead(EnGrasshopper* this, PlayState* play) { this->drawDmgEffType = ACTOR_DRAW_DMGEFF_FIRE; } - if (curFrame >= this->endFrame) { + if (curFrame >= this->animEndFrame) { this->actor.flags &= ~ACTOR_FLAG_10; EnGrasshopper_SetupFall(this); } diff --git a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.h b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.h index cf0e50cbe..a07091dd8 100644 --- a/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.h +++ b/src/overlays/actors/ovl_En_Grasshopper/z_en_grasshopper.h @@ -91,7 +91,7 @@ typedef struct EnGrasshopper { /* 0x035E */ s16 type; /* 0x0360 */ f32 dragonflyScale; /* 0x0364 */ f32 angularVelocity; - /* 0x0368 */ f32 endFrame; + /* 0x0368 */ f32 animEndFrame; /* 0x036C */ f32 approachSpeed; /* 0x0370 */ f32 baseFlyHeight; /* 0x0374 */ f32 targetPosY; diff --git a/src/overlays/actors/ovl_En_Gs/z_en_gs.c b/src/overlays/actors/ovl_En_Gs/z_en_gs.c index e3ddfee6a..55bd83106 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -250,6 +250,9 @@ void func_80997E4C(EnGs* this, PlayState* play) { case ENGS_2: this->unk_210 = this->unk_195 + 0x20F7; break; + + default: + break; } Message_ContinueTextbox(play, this->unk_210); break; @@ -260,6 +263,9 @@ void func_80997E4C(EnGs* this, PlayState* play) { } } break; + + default: + break; } } @@ -329,6 +335,9 @@ void func_8099807C(EnGs* this, PlayState* play) { func_809984F4(this, play); } break; + + default: + break; } break; @@ -339,6 +348,9 @@ void func_8099807C(EnGs* this, PlayState* play) { case 26: func_80997D14(this, play); break; + + default: + break; } } @@ -444,6 +456,9 @@ void func_8099874C(EnGs* this, PlayState* play) { case 4: phi_v0 = func_809995A4(this, play); break; + + default: + break; } if (phi_v0 == 0) { @@ -483,6 +498,9 @@ void func_8099874C(EnGs* this, PlayState* play) { SET_WEEKEVENTREG(WEEKEVENTREG_77_20); } break; + + default: + break; } if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_90_10)) { @@ -754,16 +772,16 @@ void func_80999584(Color_RGB8* arg0, Color_RGB8* arg1) { } s32 func_809995A4(EnGs* this, PlayState* play) { - static Color_RGB8 flashColours[] = { + static Color_RGB8 sFlashColours[] = { { 255, 50, 50 }, { 50, 50, 255 }, { 255, 255, 255 }, }; - static Vec3f dustAccel = { 0.0f, -0.3f, 0.0f }; - static Color_RGBA8 dustPrim = { 200, 200, 200, 128 }; - static Color_RGBA8 dustEnv = { 100, 100, 100, 0 }; - static Vec3f bomb2Velocity = { 0.0f, 0.0f, 0.0f }; - static Vec3f bomb2Accel = { 0.0f, 0.0f, 0.0f }; + static Vec3f sDustAccel = { 0.0f, -0.3f, 0.0f }; + static Color_RGBA8 sDustPrimColor = { 200, 200, 200, 128 }; + static Color_RGBA8 sDustEnvColor = { 100, 100, 100, 0 }; + static Vec3f sBomb2Velocity = { 0.0f, 0.0f, 0.0f }; + static Vec3f sBomb2Accel = { 0.0f, 0.0f, 0.0f }; s32 sp7C = -1; if (this->unk_19D == 0) { @@ -784,18 +802,18 @@ s32 func_809995A4(EnGs* this, PlayState* play) { u8 pad; this->unk_1D4--; - func_80999584(&this->unk_1FA, &flashColours[2]); + func_80999584(&this->unk_1FA, &sFlashColours[2]); if (this->unk_1D4 < 80) { if ((this->unk_1D4 % 20) < 8) { if (this->unk_1D4 < 20) { if ((this->unk_1D4 % 20) == 7) { - func_80999584(&this->unk_1FA, &flashColours[0]); + func_80999584(&this->unk_1FA, &sFlashColours[0]); this->unk_1F4 = this->unk_1FA; Audio_PlaySfx(NA_SE_SY_WARNING_COUNT_E); this->unk_200 = 0.0f; } } else if ((this->unk_1D4 % 20) == 7) { - func_80999584(&this->unk_1FA, &flashColours[1]); + func_80999584(&this->unk_1FA, &sFlashColours[1]); this->unk_1F4 = this->unk_1FA; Audio_PlaySfx(NA_SE_SY_WARNING_COUNT_N); this->unk_200 = 0.0f; @@ -826,7 +844,8 @@ s32 func_809995A4(EnGs* this, PlayState* play) { sp6C.y = this->actor.world.pos.y + 7.0f; sp6C.z = this->actor.world.pos.z + (2.0f * sp60.z); - func_800B0EB0(play, &sp6C, &sp60, &dustAccel, &dustPrim, &dustEnv, Rand_ZeroFloat(50.0f) + 200.0f, 40, 15); + func_800B0EB0(play, &sp6C, &sp60, &sDustAccel, &sDustPrimColor, &sDustEnvColor, + Rand_ZeroFloat(50.0f) + 200.0f, 40, 15); } Actor_PlaySfx_Flagged(&this->actor, NA_SE_EV_FIRE_PILLAR - SFX_FLAG); @@ -856,7 +875,7 @@ s32 func_809995A4(EnGs* this, PlayState* play) { sp54.y = this->actor.world.pos.y; sp54.z = this->actor.world.pos.z; Actor_PlaySfx(&this->actor, NA_SE_IT_BOMB_EXPLOSION); - EffectSsBomb2_SpawnLayered(play, &sp54, &bomb2Velocity, &bomb2Accel, 100, 20); + EffectSsBomb2_SpawnLayered(play, &sp54, &sBomb2Velocity, &sBomb2Accel, 100, 20); this->unk_1D4 = 10; this->unk_19A |= 8; this->unk_216 = 0; diff --git a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c index d51cf7703..7fcf32bf4 100644 --- a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c +++ b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c @@ -61,18 +61,32 @@ s32 sGuardCount = 0; s32 D_80ABBE20 = 0; -static u16 sTextIDs[] = { 0x0824, 0x0825, 0x0826, 0x082D, 0x0827, 0x0828, 0x0829, 0x082A, 0x082B, 0x082C }; +static u16 sTextIds[] = { 0x0824, 0x0825, 0x0826, 0x082D, 0x0827, 0x0828, 0x0829, 0x082A, 0x082B, 0x082C }; s16 D_80ABBE38[] = { 0x0000, 0x0000, 0x0002, 0x0001, 0x0000, 0x0000, 0x0002, 0x0000, 0x0000, 0x0002 }; -static AnimationHeader* sAnimations[] = { - &gDekuPalaceGuardWaitAnim, - &gDekuPalaceGuardWalkAnim, - &gDekuPalaceGuardDigAnim, - &gDekuPalaceGuardWalkAnim, +typedef enum { + /* -1 */ GUARD_NUTS_ANIM_NONE = -1, + /* 0 */ GUARD_NUTS_ANIM_WAIT_HEAD_TILT, + /* 1 */ GUARD_NUTS_ANIM_WALK, + /* 2 */ GUARD_NUTS_ANIM_DIG, + /* 3 */ GUARD_NUTS_ANIM_WALK_2, + /* 4 */ GUARD_NUTS_ANIM_MAX +} EnGuardNutsAnimation; + +static AnimationHeader* sAnimations[GUARD_NUTS_ANIM_MAX] = { + &gDekuPalaceGuardWaitAnim, // GUARD_NUTS_ANIM_WAIT_HEAD_TILT + &gDekuPalaceGuardWalkAnim, // GUARD_NUTS_ANIM_WALK + &gDekuPalaceGuardDigAnim, // GUARD_NUTS_ANIM_DIG + &gDekuPalaceGuardWalkAnim, // GUARD_NUTS_ANIM_WALK_2 }; -static u8 sAnimationModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE }; +static u8 sAnimationModes[GUARD_NUTS_ANIM_MAX] = { + ANIMMODE_LOOP, // GUARD_NUTS_ANIM_WAIT_HEAD_TILT + ANIMMODE_LOOP, // GUARD_NUTS_ANIM_WALK + ANIMMODE_ONCE, // GUARD_NUTS_ANIM_DIG + ANIMMODE_ONCE, // GUARD_NUTS_ANIM_WALK_2 +}; static TexturePtr sEyeTextures[] = { gDekuPalaceGuardEyeOpenTex, @@ -80,13 +94,6 @@ static TexturePtr sEyeTextures[] = { gDekuPalaceGuardEyeClosedTex, }; -typedef enum { - /* 0 */ WAIT_HEAD_TILT_ANIM, - /* 1 */ WALK_ANIM, - /* 2 */ DIG_ANIM, - /* 3 */ WALK_ANIM_2 -} EnGuardNutsAnim; - typedef enum { /* 0 */ GUARD_NUTS_WAIT_STATE, /* 1 */ GUARD_NUTS_TALKING_STATE, @@ -123,20 +130,20 @@ void EnGuardNuts_Destroy(Actor* thisx, PlayState* play) { } /** - * @brief Changes the animation to the provided index. Updates animIndex and animFrameCount for the animation. + * @brief Changes the animation to the provided index. Updates animIndex and animEndFrame for the animation. * * @param this * @param animIndex the index of sAnimations to change to */ void EnGuardNuts_ChangeAnim(EnGuardNuts* this, s32 animIndex) { this->animIndex = animIndex; - this->animFrameCount = Animation_GetLastFrame(sAnimations[this->animIndex]); - Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.0f, this->animFrameCount, + this->animEndFrame = Animation_GetLastFrame(sAnimations[this->animIndex]); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.0f, this->animEndFrame, sAnimationModes[this->animIndex], -2.0f); } void EnGuardNuts_SetupWait(EnGuardNuts* this) { - EnGuardNuts_ChangeAnim(this, WAIT_HEAD_TILT_ANIM); + EnGuardNuts_ChangeAnim(this, GUARD_NUTS_ANIM_WAIT_HEAD_TILT); this->state = GUARD_NUTS_WAIT_STATE; this->actionFunc = EnGuardNuts_Wait; } @@ -169,22 +176,22 @@ void EnGuardNuts_Wait(EnGuardNuts* this, PlayState* play) { // No place for an outsider this->guardTextIndex = 3; } - this->actor.textId = sTextIDs[this->guardTextIndex]; + this->actor.textId = sTextIds[this->guardTextIndex]; phi_a1 = this->actor.world.rot.y; if (D_80ABBE20 == 2) { EnGuardNuts_Burrow(this, play); return; } if (D_80ABBE20 == 1) { - if (this->animIndex != WALK_ANIM) { - EnGuardNuts_ChangeAnim(this, WALK_ANIM); + if (this->animIndex != GUARD_NUTS_ANIM_WALK) { + EnGuardNuts_ChangeAnim(this, GUARD_NUTS_ANIM_WALK); } phi_a1 = (this->actor.home.rot.y + 0x8000); } if (fabsf((f32)(this->actor.shape.rot.y - phi_a1)) < 100.0f) { this->actor.shape.rot.y = phi_a1; - if ((D_80ABBE20 == 1) && (this->animIndex != WALK_ANIM_2)) { - EnGuardNuts_ChangeAnim(this, WALK_ANIM_2); + if ((D_80ABBE20 == 1) && (this->animIndex != GUARD_NUTS_ANIM_WALK_2)) { + EnGuardNuts_ChangeAnim(this, GUARD_NUTS_ANIM_WALK_2); } } else { Math_SmoothStepToS(&this->actor.shape.rot.y, phi_a1, 1, 0xBB8, 0); @@ -199,7 +206,7 @@ void EnGuardNuts_Wait(EnGuardNuts* this, PlayState* play) { } void func_80ABB540(EnGuardNuts* this) { - EnGuardNuts_ChangeAnim(this, WALK_ANIM); + EnGuardNuts_ChangeAnim(this, GUARD_NUTS_ANIM_WALK); this->targetHeadPos.x = this->targetHeadPos.y = 0; this->timer = 16; this->state = GUARD_NUTS_TALKING_STATE; @@ -216,7 +223,7 @@ void func_80ABB590(EnGuardNuts* this, PlayState* play) { if (fabsf((this->actor.shape.rot.y - yaw)) < 100.0f) { this->actor.shape.rot.y = yaw; curFrame = this->skelAnime.curFrame; - if ((curFrame < this->animFrameCount) || (this->guardTextIndex >= 7)) { + if ((curFrame < this->animEndFrame) || (this->guardTextIndex >= 7)) { SkelAnime_Update(&this->skelAnime); } } else { @@ -226,8 +233,8 @@ void func_80ABB590(EnGuardNuts* this, PlayState* play) { if (Message_GetState(&play->msgCtx) == TEXT_STATE_5) { this->targetHeadPos.y = 0; this->targetHeadPos.x = 0; - if ((this->guardTextIndex == 3) && (this->animIndex == WAIT_HEAD_TILT_ANIM)) { - EnGuardNuts_ChangeAnim(this, WAIT_HEAD_TILT_ANIM); + if ((this->guardTextIndex == 3) && (this->animIndex == GUARD_NUTS_ANIM_WAIT_HEAD_TILT)) { + EnGuardNuts_ChangeAnim(this, GUARD_NUTS_ANIM_WAIT_HEAD_TILT); } if (Message_ShouldAdvance(play)) { if (D_80ABBE38[this->guardTextIndex] != 1) { @@ -238,7 +245,7 @@ void func_80ABB590(EnGuardNuts* this, PlayState* play) { EnGuardNuts_Burrow(this, play); } else { this->guardTextIndex++; - Message_StartTextbox(play, sTextIDs[this->guardTextIndex], &this->actor); + Message_StartTextbox(play, sTextIds[this->guardTextIndex], &this->actor); if (D_80ABBE38[this->guardTextIndex] == 2) { D_80ABBE20 = 1; } @@ -271,7 +278,7 @@ void func_80ABB590(EnGuardNuts* this, PlayState* play) { void EnGuardNuts_Burrow(EnGuardNuts* this, PlayState* play) { Vec3f digPos; - EnGuardNuts_ChangeAnim(this, DIG_ANIM); + EnGuardNuts_ChangeAnim(this, GUARD_NUTS_ANIM_DIG); Math_Vec3f_Copy(&digPos, &this->actor.world.pos); digPos.y = this->actor.floorHeight; EffectSsHahen_SpawnBurst(play, &digPos, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); @@ -287,7 +294,7 @@ void EnGuardNuts_SetupUnburrow(EnGuardNuts* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; SkelAnime_Update(&this->skelAnime); - if (this->animFrameCount <= curFrame) { + if (curFrame >= this->animEndFrame) { this->state = GUARD_NUTS_BURROWED_STATE; this->actionFunc = EnGuardNuts_Unburrow; this->actor.world.rot.y = this->actor.home.rot.y; @@ -327,7 +334,7 @@ void EnGuardNuts_Update(Actor* thisx, PlayState* play) { this->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; } } - if ((this->animIndex == WALK_ANIM) && + if ((this->animIndex == GUARD_NUTS_ANIM_WALK) && (Animation_OnFrame(&this->skelAnime, 1.0f) || Animation_OnFrame(&this->skelAnime, 5.0f))) { Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_WALK); } diff --git a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.h b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.h index 8cbe26f03..e07e70eaf 100644 --- a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.h +++ b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.h @@ -25,7 +25,7 @@ typedef struct EnGuardNuts { /* 0x228 */ Vec3f guardPos; /* 0x234 */ Vec3s headRot; /* 0x23A */ Vec3s targetHeadPos; - /* 0x240 */ f32 animFrameCount; + /* 0x240 */ f32 animEndFrame; /* 0x244 */ ColliderCylinder collider; } EnGuardNuts; // size = 0x290 diff --git a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c index 28b37cc91..92afb3083 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.c @@ -5,7 +5,6 @@ */ #include "z_en_guruguru.h" -#include "objects/object_fu/object_fu.h" #define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_FRIENDLY | ACTOR_FLAG_10) @@ -62,9 +61,27 @@ static ColliderCylinderInit sCylinderInit = { { 15, 20, 0, { 0, 0, 0 } }, }; -static AnimationHeader* sAnimations[] = { &gGuruGuruPlayStillAnim, &gGuruGuruPlayAndMoveHeadAnim }; -static u8 sAnimationModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP }; -static f32 sPlaySpeeds[] = { 1.0f, 1.0f }; +typedef enum { + /* 0 */ GURU_GURU_ANIM_PLAY_STILL, + /* 1 */ GURU_GURU_ANIM_PLAY_MOVE_HEAD, + /* 2 */ GURU_GURU_ANIM_MAX +} GuruGuruAnimation; + +static AnimationHeader* sAnimations[GURU_GURU_ANIM_MAX] = { + &gGuruGuruPlayStillAnim, // GURU_GURU_ANIM_PLAY_STILL + &gGuruGuruPlayAndMoveHeadAnim, // GURU_GURU_ANIM_PLAY_MOVE_HEAD +}; + +static u8 sAnimationModes[GURU_GURU_ANIM_MAX] = { + ANIMMODE_LOOP, // GURU_GURU_ANIM_PLAY_STILL + ANIMMODE_LOOP, // GURU_GURU_ANIM_PLAY_MOVE_HEAD +}; + +static f32 sPlaySpeeds[GURU_GURU_ANIM_MAX] = { + 1.0f, // GURU_GURU_ANIM_PLAY_STILL + 1.0f, // GURU_GURU_ANIM_PLAY_MOVE_HEAD +}; + static TexturePtr sEyeTextures[] = { gGuruGuruEyeClosedTex, gGuruGuruEyeAngryTex }; static TexturePtr sMouthTextures[] = { gGuruGuruMouthOpenTex, gGuruGuruMouthAngryTex }; @@ -74,7 +91,7 @@ void EnGuruguru_Init(Actor* thisx, PlayState* play) { this->actor.colChkInfo.mass = MASS_IMMOVABLE; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); SkelAnime_InitFlex(play, &this->skelAnime, &gGuruGuruSkel, &gGuruGuruPlayStillAnim, this->jointTable, - this->morphTable, 16); + this->morphTable, GURU_GURU_LIMB_MAX); this->actor.targetMode = TARGET_MODE_0; if (this->actor.params != 2) { Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); @@ -106,8 +123,8 @@ void EnGuruguru_Destroy(Actor* thisx, PlayState* play) { } void EnGuruguru_ChangeAnim(EnGuruguru* this, s32 animIndex) { - this->frameCount = Animation_GetLastFrame(sAnimations[animIndex]); - Animation_Change(&this->skelAnime, sAnimations[animIndex], sPlaySpeeds[animIndex], 0.0f, this->frameCount, + this->animEndFrame = Animation_GetLastFrame(sAnimations[animIndex]); + Animation_Change(&this->skelAnime, sAnimations[animIndex], sPlaySpeeds[animIndex], 0.0f, this->animEndFrame, sAnimationModes[animIndex], -4.0f); } @@ -115,7 +132,7 @@ void EnGuruguru_DoNothing(EnGuruguru* this, PlayState* play) { } void func_80BC6E10(EnGuruguru* this) { - EnGuruguru_ChangeAnim(this, 0); + EnGuruguru_ChangeAnim(this, GURU_GURU_ANIM_PLAY_STILL); this->textIdIndex = 0; this->unk270 = 0; if (this->actor.params == 0) { @@ -373,7 +390,7 @@ void EnGuruguru_Update(Actor* thisx, PlayState* play) { s32 EnGuruguru_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnGuruguru* this = THIS; - if (limbIndex == 14) { + if (limbIndex == GURU_GURU_LIMB_HEAD) { rot->x += this->headXRot; rot->z += this->headZRot; } diff --git a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.h b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.h index 0158e3ddc..4913d4124 100644 --- a/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.h +++ b/src/overlays/actors/ovl_En_Guruguru/z_en_guruguru.h @@ -2,6 +2,7 @@ #define Z_EN_GURUGURU_H #include "global.h" +#include "objects/object_fu/object_fu.h" struct EnGuruguru; @@ -10,8 +11,8 @@ typedef void (*EnGuruguruActionFunc)(struct EnGuruguru*, PlayState*); typedef struct EnGuruguru { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s jointTable[16]; - /* 0x1E8 */ Vec3s morphTable[16]; + /* 0x188 */ Vec3s jointTable[GURU_GURU_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[GURU_GURU_LIMB_MAX]; /* 0x248 */ EnGuruguruActionFunc actionFunc; /* 0x24C */ s16 headZRot; /* 0x24E */ s16 headXRot; @@ -22,7 +23,7 @@ typedef struct EnGuruguru { /* 0x264 */ s16 unusedTimer; // set to 6 and decremented, but never has any effect /* 0x266 */ s16 unk266; /* 0x268 */ s16 unk268; - /* 0x26C */ f32 frameCount; + /* 0x26C */ f32 animEndFrame; /* 0x270 */ u8 unk270; /* 0x272 */ s16 unk272; // set, but never used /* 0x274 */ s16 textIdIndex; diff --git a/src/overlays/actors/ovl_En_Jg/z_en_jg.c b/src/overlays/actors/ovl_En_Jg/z_en_jg.c index 20be1b6c8..7e30676e2 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -631,7 +631,7 @@ void EnJg_LullabyIntroCutsceneAction(EnJg* this, PlayState* play) { switch (play->csCtx.actorCues[cueChannel]->id) { case 1: - this->cutsceneAnimIndex = EN_JG_ANIM_CUTSCENE_IDLE; + this->csAnimIndex = EN_JG_ANIM_CUTSCENE_IDLE; if (this->drum != NULL) { Actor_Kill(this->drum); this->drum = NULL; @@ -639,50 +639,49 @@ void EnJg_LullabyIntroCutsceneAction(EnJg* this, PlayState* play) { break; case 2: - this->cutsceneAnimIndex = EN_JG_ANIM_TAKING_OUT_DRUM; + this->csAnimIndex = EN_JG_ANIM_TAKING_OUT_DRUM; break; case 3: - this->cutsceneAnimIndex = EN_JG_ANIM_DRUM_IDLE; + this->csAnimIndex = EN_JG_ANIM_DRUM_IDLE; break; case 4: - this->cutsceneAnimIndex = EN_JG_ANIM_PLAYING_DRUM; + this->csAnimIndex = EN_JG_ANIM_PLAYING_DRUM; break; case 5: - this->cutsceneAnimIndex = EN_JG_ANIM_THINKING; + this->csAnimIndex = EN_JG_ANIM_THINKING; break; case 6: - this->cutsceneAnimIndex = EN_JG_ANIM_REMEMBERING; + this->csAnimIndex = EN_JG_ANIM_REMEMBERING; break; case 7: - this->cutsceneAnimIndex = EN_JG_ANIM_STRONG_REMEMBERING; + this->csAnimIndex = EN_JG_ANIM_STRONG_REMEMBERING; break; case 8: - this->cutsceneAnimIndex = EN_JG_ANIM_DEPRESSED; + this->csAnimIndex = EN_JG_ANIM_DEPRESSED; break; case 9: - this->cutsceneAnimIndex = EN_JG_ANIM_CRADLE; + this->csAnimIndex = EN_JG_ANIM_CRADLE; break; default: - this->cutsceneAnimIndex = EN_JG_ANIM_IDLE; + this->csAnimIndex = EN_JG_ANIM_IDLE; break; } - SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->cutsceneAnimIndex); + SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->csAnimIndex); } if (!(this->flags & FLAG_DRUM_SPAWNED) && - (((this->cutsceneAnimIndex == EN_JG_ANIM_TAKING_OUT_DRUM) && Animation_OnFrame(&this->skelAnime, 14.0f) && + (((this->csAnimIndex == EN_JG_ANIM_TAKING_OUT_DRUM) && Animation_OnFrame(&this->skelAnime, 14.0f) && (this->action != EN_JG_ACTION_LULLABY_INTRO_CS)) || - (((this->cutsceneAnimIndex == EN_JG_ANIM_DRUM_IDLE) || - (this->cutsceneAnimIndex == EN_JG_ANIM_PLAYING_DRUM)) && + (((this->csAnimIndex == EN_JG_ANIM_DRUM_IDLE) || (this->csAnimIndex == EN_JG_ANIM_PLAYING_DRUM)) && (this->action == EN_JG_ACTION_LULLABY_INTRO_CS)))) { this->flags |= FLAG_DRUM_SPAWNED; this->drum = Actor_SpawnAsChildAndCutscene( @@ -691,7 +690,7 @@ void EnJg_LullabyIntroCutsceneAction(EnJg* this, PlayState* play) { this->actor.params, this->actor.csId, this->actor.halfDaysBits, NULL); } - if (this->cutsceneAnimIndex == EN_JG_ANIM_TAKING_OUT_DRUM) { + if (this->csAnimIndex == EN_JG_ANIM_TAKING_OUT_DRUM) { if (Animation_OnFrame(&this->skelAnime, 23.0f)) { Audio_PlaySfx_AtPos(&sSfxPos, NA_SE_EV_WOOD_BOUND_S); } else if (Animation_OnFrame(&this->skelAnime, 38.0f)) { diff --git a/src/overlays/actors/ovl_En_Jg/z_en_jg.h b/src/overlays/actors/ovl_En_Jg/z_en_jg.h index b63f34dce..30c84973c 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.h +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.h @@ -35,7 +35,7 @@ typedef struct EnJg { /* 0x3B0 */ Vec3f breathVelocity; /* 0x3BC */ Vec3f breathAccel; /* 0x3C8 */ s16 csId; - /* 0x3CA */ u8 cutsceneAnimIndex; + /* 0x3CA */ u8 csAnimIndex; /* 0x3CB */ u8 cueId; /* 0x3CC */ u16 flags; /* 0x3CE */ u16 textId; diff --git a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c index 694b9271d..b5819e333 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -17,7 +17,7 @@ void EnKgy_Destroy(Actor* thisx, PlayState* play); void EnKgy_Update(Actor* thisx, PlayState* play); void EnKgy_Draw(Actor* thisx, PlayState* play); -void EnKgy_ChangeAnim(EnKgy* this, s16 animIndex, u8 mode, f32 morphFrames); +void EnKgy_ChangeAnim(EnKgy* this, s16 animIndex, u8 animMode, f32 morphFrames); EnKbt* EnKgy_FindZubora(PlayState* play); ObjIcePoly* EnKgy_FindIceBlock(PlayState* play); void func_80B40D30(PlayState* play); @@ -109,7 +109,7 @@ void EnKgy_Destroy(Actor* thisx, PlayState* play) { LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); } -void EnKgy_ChangeAnim(EnKgy* this, s16 animIndex, u8 mode, f32 morphFrames) { +void EnKgy_ChangeAnim(EnKgy* this, s16 animIndex, u8 animMode, f32 morphFrames) { static AnimationHeader* sAnimations[] = { &object_kgy_Anim_004B98, &object_kgy_Anim_0008FC, &object_kgy_Anim_00292C, &object_kgy_Anim_0042E4, &object_kgy_Anim_0101F0, &object_kgy_Anim_001764, &object_kgy_Anim_003334, &object_kgy_Anim_010B84, @@ -117,7 +117,7 @@ void EnKgy_ChangeAnim(EnKgy* this, s16 animIndex, u8 mode, f32 morphFrames) { }; Animation_Change(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimations[animIndex]), mode, morphFrames); + Animation_GetLastFrame(sAnimations[animIndex]), animMode, morphFrames); this->unk_2D2 = animIndex; } diff --git a/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c b/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c index 04b5b73b8..8113526f2 100644 --- a/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c +++ b/src/overlays/actors/ovl_En_Mnk/z_en_mnk.c @@ -147,11 +147,11 @@ TexturePtr sMonkeyFaceTextures[] = { object_mnk_Tex_017120, object_mnk_Tex_017920, object_mnk_Tex_018120, }; -void EnMnk_MonkeyTiedUp_ChangeAnim(EnMnk* this, s32 animIndex, u8 mode, f32 morphFrames) { +void EnMnk_MonkeyTiedUp_ChangeAnim(EnMnk* this, s32 animIndex, u8 animMode, f32 morphFrames) { Animation_Change(&this->skelAnime, sMonkeyTiedUpAnimations[animIndex], 1.0f, 0.0f, - Animation_GetLastFrame(&sMonkeyTiedUpAnimations[animIndex]->common), mode, morphFrames); + Animation_GetLastFrame(&sMonkeyTiedUpAnimations[animIndex]->common), animMode, morphFrames); Animation_Change(&this->propSkelAnime, sMonkeyTiedUpPoleAnimations[animIndex], 1.0f, 0.0f, - Animation_GetLastFrame(&sMonkeyTiedUpPoleAnimations[animIndex]->common), mode, morphFrames); + Animation_GetLastFrame(&sMonkeyTiedUpPoleAnimations[animIndex]->common), animMode, morphFrames); switch (animIndex) { case MONKEY_TIEDUP_ANIM_KICKAROUND: @@ -184,11 +184,11 @@ void EnMnk_MonkeyTiedUp_SetNewAnim(EnMnk* this, s32 animIndex) { } } -void EnMnk_MonkeyHanging_ChangeAnim(EnMnk* this, s32 animIndex, u8 mode, f32 morphFrames) { +void EnMnk_MonkeyHanging_ChangeAnim(EnMnk* this, s32 animIndex, u8 animMode, f32 morphFrames) { Animation_Change(&this->skelAnime, sMonkeyHangingAnimations[animIndex], 1.0f, 0.0f, - Animation_GetLastFrame(&sMonkeyHangingAnimations[animIndex]->common), mode, morphFrames); + Animation_GetLastFrame(&sMonkeyHangingAnimations[animIndex]->common), animMode, morphFrames); Animation_Change(&this->propSkelAnime, sMonkeyHangingRopeAnimations[animIndex], 1.0f, 0.0f, - Animation_GetLastFrame(&sMonkeyHangingRopeAnimations[animIndex]->common), mode, morphFrames); + Animation_GetLastFrame(&sMonkeyHangingRopeAnimations[animIndex]->common), animMode, morphFrames); this->animIndex = animIndex; } @@ -196,7 +196,7 @@ void EnMnk_MonkeyHanging_SetAnim(EnMnk* this, s32 animIndex) { EnMnk_MonkeyHanging_ChangeAnim(this, animIndex, ANIMMODE_LOOP, -5.0f); } -void EnMnk_Monkey_ChangeAnim(EnMnk* this, s32 animIndex, u8 mode, f32 morphFrames) { +void EnMnk_Monkey_ChangeAnim(EnMnk* this, s32 animIndex, u8 animMode, f32 morphFrames) { s32 pad; if (animIndex == 100) { @@ -204,10 +204,10 @@ void EnMnk_Monkey_ChangeAnim(EnMnk* this, s32 animIndex, u8 mode, f32 morphFrame } if ((animIndex == 4) || (animIndex == 6)) { Animation_Change(&this->skelAnime, sMonkeyAnimations[animIndex], -1.0f, - Animation_GetLastFrame(&sMonkeyAnimations[animIndex]->common), 0.0f, mode, morphFrames); + Animation_GetLastFrame(&sMonkeyAnimations[animIndex]->common), 0.0f, animMode, morphFrames); } else { Animation_Change(&this->skelAnime, sMonkeyAnimations[animIndex], 1.0f, 0.0f, - Animation_GetLastFrame(&sMonkeyAnimations[animIndex]->common), mode, morphFrames); + Animation_GetLastFrame(&sMonkeyAnimations[animIndex]->common), animMode, morphFrames); } this->unk_3E0 = 0; this->animIndex = animIndex; diff --git a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c index ad20b3d07..9aa218e2f 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.c @@ -1182,37 +1182,40 @@ s32 EnRailgibud_PerformCutsceneActions(EnRailgibud* this, PlayState* play) { this->cueId = play->csCtx.actorCues[cueChannel]->id; switch (play->csCtx.actorCues[cueChannel]->id) { case 1: - this->cutsceneAnimIndex = EN_RAILGIBUD_ANIM_IDLE; + this->csAnimIndex = EN_RAILGIBUD_ANIM_IDLE; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_IDLE); break; case 2: - this->cutsceneAnimIndex = EN_RAILGIBUD_ANIM_SLUMP_START; + this->csAnimIndex = EN_RAILGIBUD_ANIM_SLUMP_START; Actor_PlaySfx(&this->actor, NA_SE_EN_REDEAD_WEAKENED2); Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_SLUMP_START); break; case 3: - this->cutsceneAnimIndex = EN_RAILGIBUD_ANIM_CONVULSION; + this->csAnimIndex = EN_RAILGIBUD_ANIM_CONVULSION; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_CONVULSION); break; case 4: - this->cutsceneAnimIndex = EN_RAILGIBUD_ANIM_ARMS_UP_START; + this->csAnimIndex = EN_RAILGIBUD_ANIM_ARMS_UP_START; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_ARMS_UP_START); break; case 5: - this->cutsceneAnimIndex = EN_RAILGIBUD_ANIM_WALK; + this->csAnimIndex = EN_RAILGIBUD_ANIM_WALK; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_WALK); break; + + default: + break; } } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - if (this->cutsceneAnimIndex == EN_RAILGIBUD_ANIM_SLUMP_START) { - this->cutsceneAnimIndex = EN_RAILGIBUD_ANIM_SLUMP_LOOP; + if (this->csAnimIndex == EN_RAILGIBUD_ANIM_SLUMP_START) { + this->csAnimIndex = EN_RAILGIBUD_ANIM_SLUMP_LOOP; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_SLUMP_LOOP); - } else if (this->cutsceneAnimIndex == EN_RAILGIBUD_ANIM_ARMS_UP_START) { - this->cutsceneAnimIndex = EN_RAILGIBUD_ANIM_ARMS_UP_LOOP; + } else if (this->csAnimIndex == EN_RAILGIBUD_ANIM_ARMS_UP_START) { + this->csAnimIndex = EN_RAILGIBUD_ANIM_ARMS_UP_LOOP; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, EN_RAILGIBUD_ANIM_ARMS_UP_LOOP); EnRailgibud_SetupSinkIntoGround(this); } diff --git a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h index 42b41ed8a..c9536d235 100644 --- a/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h +++ b/src/overlays/actors/ovl_En_Railgibud/z_en_railgibud.h @@ -52,7 +52,7 @@ typedef struct EnRailgibud { /* 0x3EE */ s16 shouldWalkForwardNextFrame; // Only used by the "main" Gibdo /* 0x3F0 */ union { s16 grabState; - s16 cutsceneAnimIndex; + s16 csAnimIndex; }; /* 0x3F2 */ union { s16 playerStunWaitTimer; // Cannot stun the player if this is non-zero diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index c8330232d..d54b83753 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -7580,8 +7580,8 @@ 0x80949BD4:("EnClearTag_DrawEffects",), 0x8094DEE0:("func_8094DEE0",), 0x8094DF90:("func_8094DF90",), - 0x8094DFF8:("func_8094DFF8",), - 0x8094E054:("func_8094E054",), + 0x8094DFF8:("EnGm_UpdateSkelAnime",), + 0x8094E054:("EnGm_ChangeAnim",), 0x8094E0F8:("func_8094E0F8",), 0x8094E1DC:("func_8094E1DC",), 0x8094E278:("func_8094E278",), @@ -9696,7 +9696,7 @@ 0x80A12774:("EnGo_UpdateTalking",), 0x80A12868:("EnGo_DetectCollisions",), 0x80A12954:("EnGo_UpdateSpringArrivalCutscene",), - 0x80A12A64:("EnGo_UpdateAnimationToCurrent",), + 0x80A12A64:("EnGo_UpdateSkelAnime",), 0x80A12B78:("EnGo_UpdateSfx",), 0x80A12C48:("EnGo_ChangeAnim",), 0x80A12D6C:("EnGo_UpdateEyes",), @@ -15302,8 +15302,8 @@ 0x80BB1C8C:("func_80BB1C8C",), 0x80BB1D04:("func_80BB1D04",), 0x80BB1D64:("func_80BB1D64",), - 0x80BB1FCC:("func_80BB1FCC",), - 0x80BB2020:("func_80BB2020",), + 0x80BB1FCC:("EnGeg_UpdateSkelAnime",), + 0x80BB2020:("EnGeg_ChangeAnim",), 0x80BB2088:("func_80BB2088",), 0x80BB217C:("func_80BB217C",), 0x80BB221C:("func_80BB221C",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 4b224cf3f..90edb9bf5 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -14139,7 +14139,7 @@ 0x80B3A9E4:("D_80B3A9E4","f32","",0x4), 0x80B3A9E8:("D_80B3A9E8","f32","",0x4), 0x80B3BEE0:("En_Gg2_InitVars","UNK_TYPE1","",0x1), - 0x80B3BF00:("D_80B3BF00","UNK_TYPE4","",0x4), + 0x80B3BF00:("sAnimationInfo","UNK_TYPE4","",0x4), 0x80B3C080:("D_80B3C080","UNK_TYPE4","",0x4), 0x80B3C084:("D_80B3C084","UNK_TYPE4","",0x4), 0x80B3C088:("D_80B3C088","UNK_TYPE1","",0x1), From d4c41f02633ca059d93122fe750d77062984b099 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Tue, 26 Sep 2023 21:24:52 -0700 Subject: [PATCH 2/9] z_message_nes (1 NON_MATCHING) (#1394) * Bring over progress * Some docs * scratch urls + format * Fixes * Match Message_DrawTextNES * String macros * color structs --- include/functions.h | 21 +- include/macros.h | 1 + include/variables.h | 10 +- include/z64save.h | 17 +- spec | 1 - src/code/z_message.c | 8 +- src/code/z_message_nes.c | 1728 ++++++++++++++++++++++++++++++-- tools/disasm/functions.txt | 10 +- tools/disasm/variables.txt | 13 +- tools/sizes/code_functions.csv | 6 +- 10 files changed, 1707 insertions(+), 108 deletions(-) diff --git a/include/functions.h b/include/functions.h index c24ab583d..88d8468e9 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1009,14 +1009,14 @@ void func_80148B98(PlayState* play, u8 arg1); void Message_DrawTextChar(PlayState* play, TexturePtr texture, Gfx** gfxP); void func_80149C18(PlayState* play); // void Message_FindMessage(void); -void func_80149F74(PlayState* play, u32** ppuParm2); +void Message_DrawItemIcon(PlayState* play, Gfx** gfxP); void Message_HandleOcarina(PlayState* play); void func_8014ADBC(PlayState* play, UNK_PTR puParm2); void Message_LoadItemIcon(PlayState* play, u16 itemId, s16 arg2); -void Message_LoadChar(PlayState* play, u16 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos); +void Message_SetupLoadItemIcon(PlayState* play); // void func_8014CCB4(void); // void func_8014CDF0(void); -// void func_8014CFDC(void); +// void Message_SetupLoadItemIcon(void); void func_8014D304(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); // void func_8014D62C(void); // void func_8014D7B4(void); @@ -1046,19 +1046,12 @@ void Message_Update(PlayState* play); void func_801586A4(PlayState* play); void Message_Init(PlayState* play); void Message_FindMessageNES(PlayState* play, u16 textId); -// void Message_LoadCharNES(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); -// void Message_LoadPluralRupeesNES(void); -// void Message_LoadLocalizedRupeesNES(void); -// void Message_LoadRupeesNES(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5); -// void Message_LoadTimeNES(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void Message_LoadOwlWarpTextNES(void); -// void func_80159438(void); -void func_8015966C(PlayState* play, UNK_PTR puParm2, UNK_TYPE arg3); -// void func_8015A144(void); -void func_8015B198(PlayState* play); +void Message_DrawTextNES(PlayState* play, Gfx** gfxP, u16 textDrawPos); +void Message_DecodeNES(PlayState* play); +void Message_FindCreditsMessage(PlayState* play, u16 textId); void Message_FindCreditsMessage(PlayState* play, u16 textId); void Message_DrawTextCredits(PlayState* play, Gfx** gfxP); -// void func_8015F8A8(UNK_TYPE4 ctxt); +void Message_DecodeCredits(PlayState* play); uintptr_t KaleidoManager_FaultAddrConv(uintptr_t address, void* param); void KaleidoManager_LoadOvl(KaleidoMgrOverlay* ovl); diff --git a/include/macros.h b/include/macros.h index 46932a0a6..bc7439394 100644 --- a/include/macros.h +++ b/include/macros.h @@ -38,6 +38,7 @@ #define DAY_LENGTH (CLOCK_TIME(24, 0)) #define TIME_TO_HOURS_F(time) ((time) * (24.0f / 0x10000)) +#define TIME_TO_HOURS_F_ALT(time) (TIME_TO_MINUTES_F(time) / 60.0f) #define TIME_TO_MINUTES_F(time) ((time) * ((24.0f * 60.0f) / 0x10000)) // 0.021972656f #define TIME_TO_MINUTES_ALT_F(time) ((time) / (0x10000 / (24.0f * 60.0f))) #define TIME_TO_SECONDS_F(time) ((time) * ((24.0f * 60.0f * 60.0f) / 0x10000)) diff --git a/include/variables.h b/include/variables.h index e071b2036..83427f55f 100644 --- a/include/variables.h +++ b/include/variables.h @@ -334,9 +334,9 @@ extern char D_801D039C[]; // extern UNK_TYPE1 D_801D045A; // extern UNK_TYPE1 D_801D0462; //extern UNK_TYPE1 D_801D0468; -// extern UNK_TYPE1 D_801D0470; -// extern char D_801D06F0[]; -// extern UNK_TYPE1 D_801D0710; +// extern UNK_TYPE1 sNESFontWidths; +// extern char sRupeesTextLocalization[]; +// extern UNK_TYPE1 sRupeesTextLength; // extern char D_801D0714[]; // extern UNK_TYPE1 D_801D07C4; // extern UNK_TYPE1 D_801D07DC; @@ -348,8 +348,8 @@ extern char D_801D039C[]; // extern UNK_TYPE1 D_801D08CC; // extern UNK_TYPE1 D_801D08D8; // extern UNK_TYPE1 D_801D08E4; -// extern UNK_TYPE1 D_801D08E8; -// extern UNK_TYPE1 D_801D0900; +// extern UNK_TYPE1 sMaskCodeTextENG; +// extern UNK_TYPE1 sMaskCodeTextLengthENG; extern KaleidoMgrOverlay gKaleidoMgrOverlayTable[2]; // extern UNK_TYPE1 D_801D0B8C; extern KaleidoMgrOverlay* gKaleidoMgrCurOvl; diff --git a/include/z64save.h b/include/z64save.h index c8075d9ec..1db5a566d 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -154,12 +154,22 @@ typedef enum { /* 52 */ HUD_VISIBILITY_NONE_INSTANT = 52 } HudVisibility; +// Based on sRupeesTextLocalization +typedef enum Language { + /* 0 */ LANGUAGE_JPN, + /* 1 */ LANGUAGE_ENG, + /* 2 */ LANGUAGE_GER, + /* 3 */ LANGUAGE_FRE, + /* 4 */ LANGUAGE_SPA, + /* 5 */ LANGUAGE_MAX +} Language; + typedef enum HighScore { /* 0 */ HS_BANK_RUPEES, /* 1 */ HS_UNK_1, /* 2 */ HS_FISHING, // Fishing flags /* 3 */ HS_BOAT_ARCHERY, - /* 4 */ HS_HOSRE_BACK_BALLOON, + /* 4 */ HS_HORSE_BACK_BALLOON, /* 5 */ HS_LOTTERY_GUESS, // Lottery code chosen by player (only uses lower three hex digits) /* 6 */ HS_SHOOTING_GALLERY, // High scores for both shooting galleries. Town uses lower 16 bits, Swamp uses higher 16 bits. /* 7 */ HS_MAX @@ -520,6 +530,7 @@ typedef enum { (gSaveContext.save.saveInfo.stolenItems = (gSaveContext.save.saveInfo.stolenItems & ~0x00FF0000) | ((itemId & 0xFF) << 0x10)) #define HIGH_SCORE(type) (gSaveContext.save.saveInfo.highScores[(type)]) +#define GET_HIGH_SCORE(type) ((void)0, gSaveContext.save.saveInfo.highScores[(type)]) #define HS_GET_BANK_RUPEES() (HIGH_SCORE(HS_BANK_RUPEES) & 0xFFFF) #define HS_SET_BANK_RUPEES(rupees) (HIGH_SCORE(HS_BANK_RUPEES) = ((HIGH_SCORE(HS_BANK_RUPEES) & 0xFFFF0000) | (rupees))) @@ -529,8 +540,8 @@ typedef enum { #define HS_GET_BOAT_ARCHERY_HIGH_SCORE() ((HIGH_SCORE(HS_BOAT_ARCHERY) & 0xFFFF0000) >> 0x10) #define HS_SET_BOAT_ARCHERY_HIGH_SCORE(score) (HIGH_SCORE(HS_BOAT_ARCHERY) = ((HIGH_SCORE(HS_BOAT_ARCHERY) & 0xFFFF) | ((u16)(score) << 0x10))) -#define HS_GET_HORSE_BACK_BALLOON_TIME() ((s32)HIGH_SCORE(HS_HOSRE_BACK_BALLOON)) -#define HS_SET_HORSE_BACK_BALLOON_TIME(time) (HIGH_SCORE(HS_HOSRE_BACK_BALLOON) = (time)) +#define HS_GET_HORSE_BACK_BALLOON_TIME() ((s32)HIGH_SCORE(HS_HORSE_BACK_BALLOON)) +#define HS_SET_HORSE_BACK_BALLOON_TIME(time) (HIGH_SCORE(HS_HORSE_BACK_BALLOON) = (time)) #define HS_GET_LOTTERY_CODE_GUESS() (HIGH_SCORE(HS_LOTTERY_GUESS) & 0xFFFF) #define HS_SET_LOTTERY_CODE_GUESS(guess) (HIGH_SCORE(HS_LOTTERY_GUESS) = ((HIGH_SCORE(HS_LOTTERY_GUESS) & 0xFFFF0000) | ((guess) & 0xFFFF))) diff --git a/spec b/spec index ae8d89485..2e2878c69 100644 --- a/spec +++ b/spec @@ -531,7 +531,6 @@ beginseg include "build/data/code/z_message.data.o" include "build/data/code/z_message.bss.o" include "build/src/code/z_message_nes.o" - include "build/data/code/z_message_nes.data.o" include "build/src/code/z_message_staff.o" include "build/src/code/z_player_call.o" include "build/src/code/z_shrink_window.o" diff --git a/src/code/z_message.c b/src/code/z_message.c index 37e392aec..a922f237b 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -223,7 +223,7 @@ void Message_FindMessage(PlayState* play, u16 textId) { font->messageEnd = nextSegment - foundSegment; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80149F74.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_DrawItemIcon.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_HandleOcarina.s") @@ -272,7 +272,7 @@ void func_8014CCB4(PlayState* play, s16* decodedBufPos, s32* offset, f32* arg3) #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014CDF0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014CFDC.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_SetupLoadItemIcon.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014D304.s") @@ -363,7 +363,7 @@ void func_80151A68(PlayState* play, u16 textId) { msgCtx->msgLength = 0; func_80150D08(play, textId); func_80150A84(play); - func_8015B198(play); + Message_DecodeNES(play); msgCtx->msgMode = 0x45; msgCtx->textDelayTimer = 0; msgCtx->textboxColorAlphaCurrent = msgCtx->textboxColorAlphaTarget = msgCtx->textColorAlpha = 0; @@ -548,7 +548,7 @@ void func_80153E7C(PlayState* play, Gfx** gfxP) { } else if (play->msgCtx.textIsCredits) { Message_DrawTextCredits(play, gfxP); } else { - func_8015966C(play, gfxP, 0); + Message_DrawTextNES(play, gfxP, 0); } } diff --git a/src/code/z_message_nes.c b/src/code/z_message_nes.c index 1dcb16474..6ace9acc1 100644 --- a/src/code/z_message_nes.c +++ b/src/code/z_message_nes.c @@ -2,59 +2,20 @@ #include "message_data_static.h" #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" -#if 0 - -//fontWidth -extern f32 D_801D0470[159]; - -//rupeesTextLocalization -u8 D_801D06F0[4][8] = { { "rupee(s)" }, //EN - { "rubin(e)" }, //DE - { "rubis" }, //FR - { "rupia(s)" } //SPA - }; - -// rupeesTextLength -u8 D_801D0710[4] = {8,8,5,8}; - -// sOwlWarpText -char D_801D0714[OWL_WARP_MAX][16] = { - "Great Bay Coast", // OWL_WARP_GREAT_BAY_COAST - "Zora Cape", // OWL_WARP_ZORA_CAPE - "Snowhead", // OWL_WARP_SNOWHEAD - "Mountain Village", // OWL_WARP_MOUNTAIN_VILLAGE - "Clock Town", // OWL_WARP_CLOCK_TOWN - "Milk Road", // OWL_WARP_MILK_ROAD - "Woodfall", // OWL_WARP_WOODFALL - "Southern Swamp", // OWL_WARP_SOUTHERN_SWAMP - "Ikana Canyon", // OWL_WARP_IKANA_CANYON - "Stone Tower", // OWL_WARP_STONE_TOWER - "Entrance", // OWL_WARP_ENTRANCE +// fontWidth +f32 sNESFontWidths[160] = { + 8.0f, 8.0f, 6.0f, 9.0f, 9.0f, 14.0f, 12.0f, 3.0f, 7.0f, 7.0f, 7.0f, 9.0f, 4.0f, 6.0f, 4.0f, 9.0f, + 10.0f, 5.0f, 9.0f, 9.0f, 10.0f, 9.0f, 9.0f, 9.0f, 9.0f, 9.0f, 6.0f, 6.0f, 9.0f, 11.0f, 9.0f, 11.0f, + 13.0f, 12.0f, 9.0f, 11.0f, 11.0f, 8.0f, 8.0f, 12.0f, 10.0f, 4.0f, 8.0f, 10.0f, 8.0f, 13.0f, 11.0f, 13.0f, + 9.0f, 13.0f, 10.0f, 10.0f, 9.0f, 10.0f, 11.0f, 15.0f, 11.0f, 10.0f, 10.0f, 7.0f, 10.0f, 7.0f, 10.0f, 9.0f, + 5.0f, 8.0f, 9.0f, 8.0f, 9.0f, 9.0f, 6.0f, 9.0f, 8.0f, 4.0f, 6.0f, 8.0f, 4.0f, 12.0f, 9.0f, 9.0f, + 9.0f, 9.0f, 7.0f, 8.0f, 7.0f, 8.0f, 9.0f, 12.0f, 8.0f, 9.0f, 8.0f, 7.0f, 5.0f, 7.0f, 10.0f, 6.0f, + 12.0f, 12.0f, 12.0f, 12.0f, 11.0f, 8.0f, 8.0f, 8.0f, 8.0f, 6.0f, 6.0f, 6.0f, 6.0f, 10.0f, 13.0f, 13.0f, + 13.0f, 13.0f, 10.0f, 10.0f, 10.0f, 10.0f, 9.0f, 8.0f, 8.0f, 8.0f, 8.0f, 8.0f, 9.0f, 9.0f, 9.0f, 9.0f, + 4.0f, 4.0f, 4.0f, 4.0f, 8.0f, 9.0f, 9.0f, 9.0f, 9.0f, 8.0f, 8.0f, 8.0f, 8.0f, 8.0f, 11.0f, 6.0f, + 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, 14.0f, }; -// sOwlWarpTextLength -s16 D_801D07C4[OWL_WARP_MAX] = { - 15, // OWL_WARP_GREAT_BAY_COAST - 9, // OWL_WARP_ZORA_CAPE - 8, // OWL_WARP_SNOWHEAD - 16, // OWL_WARP_MOUNTAIN_VILLAGE - 10, // OWL_WARP_CLOCK_TOWN - 9, // OWL_WARP_MILK_ROAD - 8, // OWL_WARP_WOODFALL - 14, // OWL_WARP_SOUTHERN_SWAMP - 12, // OWL_WARP_IKANA_CANYON - 11, // OWL_WARP_STONE_TOWER - 8, // OWL_WARP_ENTRANCE -}; - -#endif - -extern f32 D_801D0470[159]; -extern u8 D_801D06F0[4][8]; -extern u8 D_801D0710[4]; -extern u8 D_801D0714[OWL_WARP_MAX][16]; -extern s16 D_801D07C4[OWL_WARP_MAX]; - void Message_FindMessageNES(PlayState* play, u16 textId) { MessageContext* msgCtx = &play->msgCtx; Font* font = &msgCtx->font; @@ -102,7 +63,7 @@ void Message_LoadPluralRupeesNES(PlayState* play, s16* decodedBufPos, s32* offse s32 o = *offset; f32 f = *arg3; - msgCtx->decodedBuffer.schar[p] = 0x20; + msgCtx->decodedBuffer.schar[p] = ' '; p++; Font_LoadCharNES(play, 'R', o); o += FONT_CHAR_TEX_SIZE; @@ -134,6 +95,25 @@ void Message_LoadPluralRupeesNES(PlayState* play, s16* decodedBufPos, s32* offse *arg3 = f; } +#define RUPEES_STR_EN "Rupee(s)" +#define RUPEES_STR_DE "Rubin(e)" +#define RUPEES_STR_FR "Rubis" +#define RUPEES_STR_SPA "Rupia(s)" + +char sRupeesTextLocalization[LANGUAGE_MAX - 1][8] = { + RUPEES_STR_EN, // EN + RUPEES_STR_DE, // DE + RUPEES_STR_FR, // FR + RUPEES_STR_SPA, // SPA +}; + +u8 sRupeesTextLength[LANGUAGE_MAX - 1] = { + sizeof(RUPEES_STR_EN) - 1, + sizeof(RUPEES_STR_DE) - 1, + sizeof(RUPEES_STR_FR) - 1, + sizeof(RUPEES_STR_SPA) - 1, +}; + void Message_LoadLocalizedRupeesNES(PlayState* play, s16* decodedBufPos, s32* offset, f32* arg3) { MessageContext* msgCtx = &play->msgCtx; s16 p = *decodedBufPos; @@ -144,15 +124,15 @@ void Message_LoadLocalizedRupeesNES(PlayState* play, s16* decodedBufPos, s32* of msgCtx->decodedBuffer.schar[p] = ' '; p++; - for (j = 0; j < D_801D0710[gSaveContext.options.language - 1]; j++) { - Font_LoadCharNES(play, D_801D06F0[gSaveContext.options.language - 1][j], o); - msgCtx->decodedBuffer.schar[p] = D_801D06F0[gSaveContext.options.language - 1][j]; + for (j = 0; j < sRupeesTextLength[gSaveContext.options.language - 1]; j++) { + Font_LoadCharNES(play, sRupeesTextLocalization[gSaveContext.options.language - 1][j], o); + msgCtx->decodedBuffer.schar[p] = sRupeesTextLocalization[gSaveContext.options.language - 1][j]; o += FONT_CHAR_TEX_SIZE; p++; } p--; - f += 16.0f * msgCtx->textCharScale * (D_801D0710[gSaveContext.options.language - 1] + 1); + f += 16.0f * msgCtx->textCharScale * (sRupeesTextLength[gSaveContext.options.language - 1] + 1); *decodedBufPos = p; *offset = o; *arg3 = f; @@ -201,7 +181,7 @@ void Message_LoadRupeesNES(PlayState* play, s16* decodedBufPos, s32* offset, f32 *arg3 = f; } -void Message_LoadTimeNES(PlayState* play, u8 arg1, s32* offset, f32* arg3, s16* decodedBufPos) { +void Message_LoadTimeNES(PlayState* play, u8 curChar, s32* offset, f32* arg3, s16* decodedBufPos) { MessageContext* msgCtx = &play->msgCtx; s16 p = *decodedBufPos; s32 o = *offset; @@ -211,12 +191,11 @@ void Message_LoadTimeNES(PlayState* play, u8 arg1, s32* offset, f32* arg3, s16* f32 timeLeftInMinutes; s16 i; - if (arg1 == 0xCF) { + if (curChar == 0xCF) { timeLeft = TIME_UNTIL_MOON_CRASH; } else { timeLeft = TIME_UNTIL_NEW_DAY; } - timeLeftInMinutes = TIME_TO_MINUTES_F(timeLeft); digits[0] = 0; @@ -252,6 +231,46 @@ void Message_LoadTimeNES(PlayState* play, u8 arg1, s32* offset, f32* arg3, s16* *arg3 = f; } +#define GREAT_BAY_COAST_STR "Great Bay Coast" +#define ZORA_CAPE_STR "Zora Cape" +#define SNOWHEAD_STR "Snowhead" +#define MOUNTAIN_VILLAGE_STR "Mountain Village" +#define CLOCK_TOWN_STR "Clock Town" +#define MILK_ROAD_STR "Milk Road" +#define WOODFALL_STR "Woodfall" +#define SOUTHERN_SWAMP_STR "Southern Swamp" +#define IKANA_CANYON_STR "Ikana Canyon" +#define STONE_TOWER_STR "Stone Tower" +#define ENTRANCE_STR "Entrance" + +char sOwlWarpTextENG[OWL_WARP_MAX][16] = { + GREAT_BAY_COAST_STR, // OWL_WARP_GREAT_BAY_COAST + ZORA_CAPE_STR, // OWL_WARP_ZORA_CAPE + SNOWHEAD_STR, // OWL_WARP_SNOWHEAD + MOUNTAIN_VILLAGE_STR, // OWL_WARP_MOUNTAIN_VILLAGE + CLOCK_TOWN_STR, // OWL_WARP_CLOCK_TOWN + MILK_ROAD_STR, // OWL_WARP_MILK_ROAD + WOODFALL_STR, // OWL_WARP_WOODFALL + SOUTHERN_SWAMP_STR, // OWL_WARP_SOUTHERN_SWAMP + IKANA_CANYON_STR, // OWL_WARP_IKANA_CANYON + STONE_TOWER_STR, // OWL_WARP_STONE_TOWER + ENTRANCE_STR, // OWL_WARP_ENTRANCE +}; + +s16 sOwlWarpTextLengthENG[OWL_WARP_MAX] = { + sizeof(GREAT_BAY_COAST_STR) - 1, // OWL_WARP_GREAT_BAY_COAST + sizeof(ZORA_CAPE_STR) - 1, // OWL_WARP_ZORA_CAPE + sizeof(SNOWHEAD_STR) - 1, // OWL_WARP_SNOWHEAD + sizeof(MOUNTAIN_VILLAGE_STR) - 1, // OWL_WARP_MOUNTAIN_VILLAGE + sizeof(CLOCK_TOWN_STR) - 1, // OWL_WARP_CLOCK_TOWN + sizeof(MILK_ROAD_STR) - 1, // OWL_WARP_MILK_ROAD + sizeof(WOODFALL_STR) - 1, // OWL_WARP_WOODFALL + sizeof(SOUTHERN_SWAMP_STR) - 1, // OWL_WARP_SOUTHERN_SWAMP + sizeof(IKANA_CANYON_STR) - 1, // OWL_WARP_IKANA_CANYON + sizeof(STONE_TOWER_STR) - 1, // OWL_WARP_STONE_TOWER + sizeof(ENTRANCE_STR) - 1, // OWL_WARP_ENTRANCE +}; + void Message_LoadOwlWarpTextNES(PlayState* play, s32* offset, f32* arg2, s16* decodedBufPos) { MessageContext* msgCtx = &play->msgCtx; s16 p = *decodedBufPos; @@ -267,18 +286,18 @@ void Message_LoadOwlWarpTextNES(PlayState* play, s32* offset, f32* arg2, s16* de } else { owlWarpId = play->pauseCtx.cursorPoint[PAUSE_WORLD_MAP]; } - stringLimit = D_801D07C4[owlWarpId]; + stringLimit = sOwlWarpTextLengthENG[owlWarpId]; for (i = 0; i < stringLimit; i++) { - msgCtx->decodedBuffer.schar[p] = D_801D0714[owlWarpId][i]; + msgCtx->decodedBuffer.schar[p] = sOwlWarpTextENG[owlWarpId][i]; currentChar = msgCtx->decodedBuffer.schar[p]; if (currentChar != ' ') { - Font_LoadCharNES(play, D_801D0714[owlWarpId][i], o); + Font_LoadCharNES(play, sOwlWarpTextENG[owlWarpId][i], o); o += FONT_CHAR_TEX_SIZE; } currentChar = msgCtx->decodedBuffer.schar[p]; p++; - f += (D_801D0470[currentChar - ' '] * msgCtx->textCharScale); + f += (sNESFontWidths[currentChar - ' '] * msgCtx->textCharScale); } p--; @@ -288,8 +307,1585 @@ void Message_LoadOwlWarpTextNES(PlayState* play, s32* offset, f32* arg2, s16* de *arg2 = f; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_80159438.s") +void Message_GetTimerDigitsNES(OSTime time, s16* digits) { + OSTime t = time; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_8015966C.s") + // 6 minutes + digits[0] = t / SECONDS_TO_TIMER(360); + t -= (digits[0] * SECONDS_TO_TIMER(360)); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/func_8015B198.s") + // minutes + digits[1] = t / SECONDS_TO_TIMER(60); + t -= (digits[1] * SECONDS_TO_TIMER(60)); + + digits[2] = '\''; + + // 10 seconds + digits[3] = t / SECONDS_TO_TIMER(10); + t -= digits[3] * SECONDS_TO_TIMER(10); + + // seconds + digits[4] = t / SECONDS_TO_TIMER(1); + t -= digits[4] * SECONDS_TO_TIMER(1); + + digits[5] = '"'; + + // 100 milliseconds + digits[6] = t / SECONDS_TO_TIMER_PRECISE(0, 10); + t -= digits[6] * SECONDS_TO_TIMER_PRECISE(0, 10); + + // 10 milliseconds + digits[7] = t; + + digits[0] += '0'; + digits[1] += '0'; + digits[3] += '0'; + digits[4] += '0'; + digits[6] += '0'; + digits[7] += '0'; +} + +Color_RGB16 D_801D07DC[] = { + { 255, 120, 0 }, { 70, 255, 80 }, { 80, 110, 255 }, { 255, 255, 30 }, + { 90, 180, 255 }, { 210, 100, 255 }, { 170, 170, 170 }, { 255, 130, 30 }, +}; + +Color_RGB16 D_801D080C[] = { + { 255, 60, 60 }, { 70, 255, 80 }, { 80, 90, 255 }, { 255, 255, 50 }, + { 80, 150, 255 }, { 255, 150, 180 }, { 170, 170, 170 }, { 255, 130, 30 }, +}; + +Color_RGB16 D_801D083C[] = { + { 255, 60, 60 }, { 70, 255, 80 }, { 80, 90, 255 }, { 255, 255, 50 }, + { 80, 150, 255 }, { 255, 150, 180 }, { 180, 180, 200 }, { 255, 130, 30 }, +}; + +Color_RGB16 D_801D086C[] = { + { 195, 0, 0 }, { 70, 255, 80 }, { 80, 90, 255 }, { 255, 255, 50 }, + { 80, 150, 255 }, { 255, 150, 180 }, { 170, 170, 170 }, { 255, 130, 30 }, +}; + +Color_RGB16 D_801D089C[] = { + { 255, 60, 60 }, { 110, 170, 255 }, { 80, 90, 255 }, { 255, 255, 50 }, + { 80, 150, 255 }, { 255, 150, 180 }, { 170, 170, 170 }, { 255, 130, 30 }, +}; + +u8 D_801D08CC[] = { + 0x02, 0x01, 0x03, 0x06, 0x06, 0x06, 0x03, 0x03, 0x03, 0x03, 0x01, 0x06, +}; + +void Message_DrawTextNES(PlayState* play, Gfx** gfxP, u16 textDrawPos) { + MessageContext* msgCtx = &play->msgCtx; + u16 i; + u16 j; + Font* font = &msgCtx->font; + u16 charTexIndex; + u16 stateTimerHi; + Gfx* gfx = *gfxP; + u16 character; + s16 sp130; + s16 sp12E; + s16 sp12C; + s16 sp12A; + + msgCtx->textPosX = msgCtx->unk11F1A[0] + msgCtx->unk11FF8; + msgCtx->textPosY = msgCtx->unk11FFA; + + sp130 = 0; + if (!msgCtx->textIsCredits) { + msgCtx->textPosY = msgCtx->unk11FFA; + } else { + msgCtx->textPosY = 48; + } + + if (msgCtx->itemId != 0xFE) { + Message_DrawItemIcon(play, &gfx); + } + + msgCtx->textColorR = msgCtx->unk120C8; + msgCtx->textColorG = msgCtx->unk120CA; + msgCtx->textColorB = msgCtx->unk120CC; + + charTexIndex = 0; + + for (i = textDrawPos; i < msgCtx->textDrawPos; i++) { + character = msgCtx->decodedBuffer.schar[i]; + + switch (character) { + case 0x0: + if (play->pauseCtx.bombersNotebookOpen || (msgCtx->textBoxType == TEXTBOX_TYPE_D)) { + msgCtx->textColorR = msgCtx->textColorG = msgCtx->textColorB = 0; + } else if (msgCtx->textBoxType == TEXTBOX_TYPE_5) { + msgCtx->textColorR = msgCtx->textColorG = msgCtx->textColorB = 0; + } else { + msgCtx->textColorR = msgCtx->textColorG = msgCtx->textColorB = 255; + } + + if ((i + 1) == msgCtx->textDrawPos) { + msgCtx->textDrawPos++; + } + break; + + case 0x1: + case 0x2: + case 0x3: + case 0x4: + case 0x5: + case 0x6: + case 0x7: + case 0x8: + if ((msgCtx->msgMode >= MSGMODE_NEW_CYCLE_0) && (msgCtx->msgMode <= MSGMODE_OWL_SAVE_2) && + (character == 0x2)) { + msgCtx->textDrawPos = msgCtx->decodedTextLen; + if (msgCtx->unk120D6) { + msgCtx->unk120D4 += 25; + if (msgCtx->unk120D4 >= 100) { + msgCtx->unk120D6 = false; + } + } else { + msgCtx->unk120D4 -= 25; + if (msgCtx->unk120D4 <= -100) { + msgCtx->unk120D6 = true; + } + } + + if (D_801D07DC[(s16)(character - 1)].r + msgCtx->unk120D4 < 0) { + msgCtx->textColorR = 0; + } else { + msgCtx->textColorR = D_801D07DC[(s16)(character - 1)].r + msgCtx->unk120D4; + } + + if (D_801D07DC[(s16)(character - 1)].g + msgCtx->unk120D4 >= 255) { + msgCtx->textColorG = D_801D07DC[(s16)(character - 1)].g; + } else { + msgCtx->textColorG = D_801D07DC[(s16)(character - 1)].g + msgCtx->unk120D4; + } + + if (D_801D07DC[(s16)(character - 1)].b + msgCtx->unk120D4 < 0) { + msgCtx->textColorB = 0; + } else { + msgCtx->textColorB = D_801D07DC[(s16)(character - 1)].b + msgCtx->unk120D4; + } + + } else if (play->pauseCtx.bombersNotebookOpen) { + msgCtx->textColorR = D_801D089C[(s16)(character - 1)].r; + msgCtx->textColorG = D_801D089C[(s16)(character - 1)].g; + msgCtx->textColorB = D_801D089C[(s16)(character - 1)].b; + } else if (msgCtx->textBoxType == TEXTBOX_TYPE_1) { + msgCtx->textColorR = D_801D07DC[(s16)(character - 1)].r; + msgCtx->textColorG = D_801D07DC[(s16)(character - 1)].g; + msgCtx->textColorB = D_801D07DC[(s16)(character - 1)].b; + } else if (msgCtx->textBoxType == TEXTBOX_TYPE_D) { + msgCtx->textColorR = D_801D086C[(s16)(character - 1)].r; + msgCtx->textColorG = D_801D086C[(s16)(character - 1)].g; + msgCtx->textColorB = D_801D086C[(s16)(character - 1)].b; + } else { + msgCtx->textColorR = D_801D080C[(s16)(character - 1)].r; + msgCtx->textColorG = D_801D080C[(s16)(character - 1)].g; + msgCtx->textColorB = D_801D080C[(s16)(character - 1)].b; + } + + if ((i + 1) == msgCtx->textDrawPos) { + msgCtx->textDrawPos++; + } + break; + + case 0x20: // ` ` + msgCtx->textPosX += 6; + break; + + case 0x11: + msgCtx->textPosY += msgCtx->unk11FFC; + // fallthrough + case 0x13: + sp130++; + + msgCtx->textPosX = msgCtx->unk11F1A[sp130] + msgCtx->unk11FF8; + if (msgCtx->choiceNum == 1) { + if (!play->pauseCtx.bombersNotebookOpen) { + msgCtx->textPosX += 16; + } else { + msgCtx->textPosX += 50; + } + } else if (msgCtx->choiceNum == 2) { + if (msgCtx->unk120D8 != 3) { + if (!play->pauseCtx.bombersNotebookOpen) { + msgCtx->textPosX += 10; + } else { + msgCtx->textPosX += 57; + } + } else if (sp130 >= 2) { + if (!play->pauseCtx.bombersNotebookOpen) { + msgCtx->textPosX += 10; + } else { + msgCtx->textPosX += 57; + } + } + } + continue; + + case 0x10: + case 0x12: + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + if (!msgCtx->textboxSkipped) { + Audio_PlaySfx(NA_SE_NONE); + msgCtx->msgMode = MSGMODE_TEXT_AWAIT_NEXT; + Font_LoadMessageBoxEndIcon(font, 0); + } else { + msgCtx->msgMode = MSGMODE_TEXT_NEXT_MSG; + msgCtx->textUnskippable = false; + msgCtx->msgBufPos++; + } + msgCtx->unk120CE = msgCtx->textColorR; + msgCtx->unk120D0 = msgCtx->textColorG; + msgCtx->unk120D2 = msgCtx->textColorB; + } + *gfxP = gfx; + return; + + case 0x17: // MESSAGE_QUICKTEXT_ENABLE + if ((i + 1) == msgCtx->textDrawPos) { + j = i; + if ((msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) || + ((msgCtx->msgMode >= MSGMODE_OCARINA_STARTING) && (msgCtx->msgMode <= MSGMODE_26))) { + //! FAKE: + dummy:; + while (true) { + if ((msgCtx->decodedBuffer.schar[j] != 0x18) && (msgCtx->decodedBuffer.schar[j] != 0x1A) && + (msgCtx->decodedBuffer.schar[j] != 0x19) && (msgCtx->decodedBuffer.schar[j] != 0xE0) && + (msgCtx->decodedBuffer.schar[j] != 0x10) && (msgCtx->decodedBuffer.schar[j] != 0x12)) { + j++; + continue; + } + break; + } + i = j - 1; + msgCtx->textDrawPos = i + 1; + } + } + break; + + case 0x18: // MESSAGE_QUICKTEXT_DISABLE + break; + + case 0x1B: // MESSAGE_BOX_BREAK_DELAYED + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + stateTimerHi = msgCtx->decodedBuffer.schar[++i] << 8; + stateTimerHi |= msgCtx->decodedBuffer.schar[++i]; + msgCtx->stateTimer = stateTimerHi; + msgCtx->msgMode = MSGMODE_TEXT_DELAYED_BREAK; + } + *gfxP = gfx; + return; + + case 0x1C: + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + msgCtx->msgMode = MSGMODE_TEXT_DONE; + if (msgCtx->unk11F0C == 3) { + msgCtx->textboxEndType = 0x55; + } else { + msgCtx->textboxEndType = 0x50; + } + stateTimerHi = msgCtx->decodedBuffer.schar[++i] << 8; + stateTimerHi |= msgCtx->decodedBuffer.schar[++i]; + msgCtx->stateTimer = stateTimerHi; + Font_LoadMessageBoxEndIcon(font, 1); + if (play->csCtx.state == CS_STATE_IDLE) { + func_8011552C(play, DO_ACTION_RETURN); + } + } + *gfxP = gfx; + return; + + case 0x1D: + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + msgCtx->msgMode = MSGMODE_TEXT_DONE; + msgCtx->textboxEndType = 0x52; + stateTimerHi = msgCtx->decodedBuffer.schar[++i] << 8; + stateTimerHi |= msgCtx->decodedBuffer.schar[++i]; + msgCtx->stateTimer = stateTimerHi; + Font_LoadMessageBoxEndIcon(font, 1); + if (play->csCtx.state == CS_STATE_IDLE) { + func_8011552C(play, DO_ACTION_RETURN); + } + } + *gfxP = gfx; + return; + + case 0x1E: // MESSAGE_SFX + if (((i + 1) == msgCtx->textDrawPos) && (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING)) { + stateTimerHi = msgCtx->decodedBuffer.schar[i + 1] << 8; + stateTimerHi |= msgCtx->decodedBuffer.schar[i + 2]; + Audio_PlaySfx(stateTimerHi); + } + if ((i + 1) == msgCtx->textDrawPos) { + msgCtx->textDrawPos += 2; + } + i += 2; + break; + + case 0x1F: + if (((i + 1) == msgCtx->textDrawPos) && (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING)) { + msgCtx->msgMode = MSGMODE_9; + stateTimerHi = msgCtx->decodedBuffer.schar[i + 1] << 8; + stateTimerHi |= msgCtx->decodedBuffer.schar[i + 2]; + msgCtx->textDelayTimer = stateTimerHi; + } + i += 2; + break; + + case 0xA: + i++; + character = msgCtx->decodedBuffer.schar[i]; + switch (character) { + case 0x0: + case 0x1: + case 0x2: + case 0x3: + case 0x4: + case 0x5: + case 0x6: + msgCtx->textDelay = character - 0x0; + if ((i + 1) == msgCtx->textDrawPos) { + msgCtx->textDrawPos++; + } + break; + } + break; + + case 0xC1: // MESSAGE_BACKGROUND + msgCtx->textPosX = 0x2D; + + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + Audio_PlaySfx(NA_SE_NONE); + } + + gDPPipeSync(gfx++); + gDPSetCombineMode(gfx++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); + gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, msgCtx->textColorAlpha); + gDPLoadTextureBlock_4b(gfx++, msgCtx->textboxSegment + 0x1000, G_IM_FMT_I, 96, 48, 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); + gSPTextureRectangle(gfx++, msgCtx->textPosX << 2, (msgCtx->unk12012 + 1) << 2, + (msgCtx->textPosX + 0x60) << 2, (msgCtx->unk12012 + 0x31) << 2, G_TX_RENDERTILE, 0, + 0, 1 << 10, 1 << 10); + gDPLoadTextureBlock_4b(gfx++, msgCtx->textboxSegment + 0x1900, G_IM_FMT_I, 96, 48, 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); + gSPTextureRectangle(gfx++, (msgCtx->textPosX + 0x60) << 2, (msgCtx->unk12012 + 1) << 2, + (msgCtx->textPosX + 0xC1) << 2, (msgCtx->unk12012 + 0x31) << 2, G_TX_RENDERTILE, 0, + 0, 1 << 10, 1 << 10); + + gDPPipeSync(gfx++); + gDPSetPrimColor(gfx++, 0, 0, 255, 60, 0, msgCtx->textColorAlpha); + gDPLoadTextureBlock_4b(gfx++, msgCtx->textboxSegment + 0x1000, G_IM_FMT_I, 96, 48, 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); + gSPTextureRectangle(gfx++, msgCtx->textPosX << 2, msgCtx->unk12012 << 2, (msgCtx->textPosX + 0x60) << 2, + (msgCtx->unk12012 + 0x30) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); + gDPLoadTextureBlock_4b(gfx++, msgCtx->textboxSegment + 0x1900, G_IM_FMT_I, 96, 48, 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); + gSPTextureRectangle(gfx++, (msgCtx->textPosX + 0x60) << 2, msgCtx->unk12012 << 2, + (msgCtx->textPosX + 0xC0) << 2, (msgCtx->unk12012 + 0x30) << 2, G_TX_RENDERTILE, 0, + 0, 1 << 10, 1 << 10); + + gDPPipeSync(gfx++); + gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, + PRIMITIVE, 0); + + msgCtx->textPosX += 32; + break; + + case 0xC2: + msgCtx->textboxEndType = 0x10; + + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + msgCtx->choiceTextId = msgCtx->currentTextId; + msgCtx->stateTimer = 4; + Font_LoadMessageBoxEndIcon(font, 2); + if (msgCtx->unk120D8 != 3) { + msgCtx->unk11FFE[0] = (s16)(msgCtx->textboxYTarget + 0xE); + msgCtx->unk11FFE[1] = (s16)(msgCtx->textboxYTarget + 0x1A); + msgCtx->unk11FFE[2] = (s16)(msgCtx->textboxYTarget + 0x26); + } + } + break; + + case 0xC3: + msgCtx->textboxEndType = 0x11; + + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + msgCtx->choiceTextId = msgCtx->currentTextId; + msgCtx->stateTimer = 4; + Font_LoadMessageBoxEndIcon(font, 2); + if (msgCtx->unk120D8 != 3) { + msgCtx->unk11FFE[0] = (s16)(msgCtx->textboxYTarget + 0xE); + msgCtx->unk11FFE[1] = (s16)(msgCtx->textboxYTarget + 0x1A); + msgCtx->unk11FFE[2] = (s16)(msgCtx->textboxYTarget + 0x26); + } + } + break; + + case 0xCC: + msgCtx->textboxEndType = 0x60; + + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + Font_LoadMessageBoxEndIcon(font, 1); + } + break; + + case 0xD0: + msgCtx->textboxEndType = 0x61; + + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + Font_LoadMessageBoxEndIcon(font, 1); + } + break; + + case 0xD1: + msgCtx->textboxEndType = 0x62; + + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + Font_LoadMessageBoxEndIcon(font, 1); + } + break; + + case 0xD2: + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + msgCtx->msgMode = MSGMODE_TEXT_DONE; + msgCtx->textboxEndType = 0x41; + Font_LoadMessageBoxEndIcon(font, 0); + Audio_PlaySfx(NA_SE_SY_MESSAGE_END); + } + break; + + case 0xD5: + msgCtx->textboxEndType = 0x63; + + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + Font_LoadMessageBoxEndIcon(font, 1); + } + break; + + case 0x15: + case 0xBF: + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + if (msgCtx->textBoxType == TEXTBOX_TYPE_3) { + Message_HandleOcarina(play); + *gfxP = gfx; + return; + } + + msgCtx->msgMode = MSGMODE_TEXT_DONE; + if (msgCtx->textboxEndType == 0) { + Audio_PlaySfx(NA_SE_SY_MESSAGE_END); + if (character == 0xBF) { + Font_LoadMessageBoxEndIcon(font, 1); + } else { + Font_LoadMessageBoxEndIcon(font, 0); + } + if (play->csCtx.state == CS_STATE_IDLE) { + func_8011552C(play, DO_ACTION_RETURN); + } + } else { + Audio_PlaySfx(NA_SE_NONE); + } + } + *gfxP = gfx; + return; + + case 0x1A: + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + Audio_PlaySfx(NA_SE_NONE); + msgCtx->msgMode = MSGMODE_TEXT_DONE; + msgCtx->textboxEndType = 0x30; + } + *gfxP = gfx; + return; + + case 0x19: + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + msgCtx->msgMode = MSGMODE_TEXT_DONE; + msgCtx->textboxEndType = 0x40; + Font_LoadMessageBoxEndIcon(font, 0); + Audio_PlaySfx(NA_SE_SY_MESSAGE_END); + } + *gfxP = gfx; + return; + + case 0xE0: + if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { + msgCtx->msgMode = MSGMODE_TEXT_DONE; + msgCtx->textboxEndType = 0x42; + Font_LoadMessageBoxEndIcon(font, 1); + Audio_PlaySfx(NA_SE_SY_MESSAGE_END); + } + *gfxP = gfx; + return; + + default: + switch (character) { + case 0x8169: + case 0x8175: + msgCtx->textPosX -= (s16)(6.0f * msgCtx->textCharScale); + break; + + case 0x8145: + msgCtx->textPosX -= (s16)(3.0f * msgCtx->textCharScale); + break; + + case 0x8148: + case 0x8149: + msgCtx->textPosX -= (s16)(2.0f * msgCtx->textCharScale); + break; + + default: + break; + } + if ((msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) && ((i + 1) == msgCtx->textDrawPos)) { + Audio_PlaySfx(NA_SE_NONE); + } + if ((character >= 0xB0) && (character <= 0xBB)) { + sp12E = msgCtx->textColorR; + sp12C = msgCtx->textColorG; + sp12A = msgCtx->textColorB; + msgCtx->textColorR = D_801D083C[(s16)D_801D08CC[character - 0xB0]].r; + msgCtx->textColorG = D_801D083C[(s16)D_801D08CC[character - 0xB0]].g; + msgCtx->textColorB = D_801D083C[(s16)D_801D08CC[character - 0xB0]].b; + Message_DrawTextChar(play, &font->charBuf[font->unk_11D88][charTexIndex], &gfx); + msgCtx->textColorR = sp12E; + msgCtx->textColorG = sp12C; + msgCtx->textColorB = sp12A; + } else if (msgCtx->msgMode >= MSGMODE_OWL_SAVE_0) { + if ((i < (msgCtx->decodedTextLen - 6)) || (i >= (msgCtx->decodedTextLen - 4))) { + Message_DrawTextChar(play, &font->charBuf[font->unk_11D88][charTexIndex], &gfx); + } + } else { + Message_DrawTextChar(play, &font->charBuf[font->unk_11D88][charTexIndex], &gfx); + } + charTexIndex += FONT_CHAR_TEX_SIZE; + + //! @TODO: u8 character but > 0x255 cases + switch (character) { + case 0x8144: + msgCtx->textPosX += (s16)(8.0f * msgCtx->textCharScale); + break; + + case 0x816A: + case 0x8176: + msgCtx->textPosX += (s16)(10.0f * msgCtx->textCharScale); + break; + + case 0x8141: + case 0x8142: + case 0x8168: + msgCtx->textPosX += (s16)(12.0f * msgCtx->textCharScale); + break; + + case 0x8194: + msgCtx->textPosX += (s16)(14.0f * msgCtx->textCharScale); + break; + + case 0x8145: + msgCtx->textPosX += (s16)(15.0f * msgCtx->textCharScale); + break; + + default: + if (((msgCtx->textboxEndType == 0x62) && (i >= msgCtx->unk120C0) && + ((msgCtx->unk120C0 + 4) >= i)) || + ((msgCtx->textboxEndType == 0x63) && (i >= msgCtx->unk120C0) && + ((msgCtx->unk120C0 + 2) >= i)) || + ((msgCtx->textboxEndType == 0x60) && (i >= msgCtx->unk120C0) && + ((msgCtx->unk120C0 + 2) >= i)) || + ((msgCtx->textboxEndType == 0x61) && (i >= msgCtx->unk120C0) && + ((msgCtx->unk120C0 + 1) >= i))) { + msgCtx->textPosX += (s32)(16.0f * msgCtx->textCharScale); + } else { + msgCtx->textPosX += (s32)(sNESFontWidths[character - ' '] * msgCtx->textCharScale); + } + break; + } + break; + } + } + + if (msgCtx->textDelayTimer == 0) { + msgCtx->textDrawPos = i + 1; + msgCtx->textDelayTimer = 0; + if (msgCtx->msgMode == MSGMODE_9) { + msgCtx->msgMode = MSGMODE_TEXT_DISPLAYING; + } + } else { + msgCtx->textDelayTimer--; + } + + *gfxP = gfx; +} + +char D_801D08D8[][4] = { + "Fast", + "----", + "Slow", +}; + +u8 D_801D08E4[] = { + 0x01, + 0x03, + 0x04, + 0x02, +}; + +#define RED_STR "RED" +#define BLUE_STR "BLUE" +#define YELLOW_STR "YELLOW" +#define GREEN_STR "GREEN" + +char sMaskCodeTextENG[][6] = { + RED_STR, + BLUE_STR, + YELLOW_STR, + GREEN_STR, +}; + +u8 sMaskCodeTextLengthENG[] = { + sizeof(RED_STR) - 1, + sizeof(BLUE_STR) - 1, + sizeof(YELLOW_STR) - 1, + sizeof(GREEN_STR) - 1, +}; + +#ifdef NON_MATCHING +// https://decomp.me/scratch/w2ckG +void Message_DecodeNES(PlayState* play) { + f32 var_fs0; + MessageContext* msgCtx = &play->msgCtx; + u8* ptr; + Font* font = &msgCtx->font; // spE0 + Player* player; // spDC + s16 decodedBufPos; // spDA + s16 value; + u32 timeToMoonCrash; + s16 i; // s1 + s16 spD0; // numLines + s16 digits[4]; // spC8/CA/CC/CE + s16 spC6; + f32 timeInSeconds; + s32 charTexIdx; // spBC + s16 loadChar; + s16 spA8[8]; + f32 spA4; + s16 playerNameLen; // s0 + s16 var_v1_3; + u8 curChar; // sp78 + s8 charOffset; + s16 temp_s2_2; + s16 var_s2_9; + + player = GET_PLAYER(play); + decodedBufPos = 0; + spC6 = 0; + charTexIdx = 0; + spD0 = 0; + msgCtx->textDelayTimer = 0; + msgCtx->textDelay = msgCtx->textDelayTimer; + msgCtx->textFade = 0; + spA4 = 0.0f; + font->unk_11D88 = (font->unk_11D88 ^ 1) & 1; + Message_SetupLoadItemIcon(play); + + while (true) { + curChar = font->msgBuf.schar[msgCtx->msgBufPos]; + msgCtx->decodedBuffer.schar[decodedBufPos] = font->msgBuf.schar[msgCtx->msgBufPos]; + + if ((curChar == 0x10) || (curChar == 0x12) || (curChar == 0x1B) || (curChar == 0x1C) || (curChar == 0x1D) || + (curChar == 0x19) || (curChar == 0xE0) || (curChar == 0xBF) || (curChar == 0x15) || (curChar == 0x1A)) { + msgCtx->msgMode = MSGMODE_TEXT_DISPLAYING; + msgCtx->textDrawPos = 1; + if (msgCtx->textBoxType == TEXTBOX_TYPE_3) { + msgCtx->unk11FFA = msgCtx->textboxY + 2; + } else { + msgCtx->unk11FFA = msgCtx->textboxY + 8; + } + msgCtx->unk11F1A[spC6] = 0; + if (msgCtx->unk11F18 != 0) { + msgCtx->unk11F1A[spC6] = (s16)((msgCtx->textCharScale * 16.0f * 16.0f) - spA4) / 2; + } + spA4 = 0.0f; + if (curChar == 0x12) { + if ((msgCtx->textBoxType != TEXTBOX_TYPE_3) && (msgCtx->textBoxType != TEXTBOX_TYPE_4)) { + if (spD0 < 2) { + msgCtx->unk11FFA = msgCtx->textboxY + XREG(10); + } else if (spD0 == 2) { + msgCtx->unk11FFA = msgCtx->textboxY + XREG(11); + } else if (spD0 == 3) { + msgCtx->unk11FFA = msgCtx->textboxY + XREG(12); + } + } + } else { + if ((msgCtx->textBoxType != TEXTBOX_TYPE_3) && (msgCtx->textBoxType != TEXTBOX_TYPE_4)) { + if (spD0 == 0) { + msgCtx->unk11FFA = msgCtx->textboxY + XREG(13) + XREG(10); + } else if (spD0 == 1) { + msgCtx->unk11FFA = msgCtx->textboxY + XREG(13) + XREG(11); + } else if (spD0 == 2) { + msgCtx->unk11FFA = msgCtx->textboxY + XREG(13) + XREG(12); + } + } + } + + //! FAKE: Perhaps a locally required temp for scoping + dummy:; + if ((curChar == 0x1B) || (curChar == 0x1C) || (curChar == 0x1D)) { + //! FAKE: & 0xFFFF to fix regalloc + msgCtx->decodedBuffer.schar[++decodedBufPos] = font->msgBuf.schar[msgCtx->msgBufPos + 1] & 0xFFFF; + msgCtx->decodedBuffer.schar[++decodedBufPos] = font->msgBuf.schar[msgCtx->msgBufPos + 2]; + msgCtx->msgBufPos += 3; + } + msgCtx->decodedTextLen = decodedBufPos; + msgCtx->unk120D8 = spD0; + if (msgCtx->textboxSkipped || (msgCtx->textBoxType == TEXTBOX_TYPE_1) || + (msgCtx->textBoxType == TEXTBOX_TYPE_3) || (msgCtx->textBoxType == TEXTBOX_TYPE_6) || + (msgCtx->textBoxType == TEXTBOX_TYPE_8) || (msgCtx->textBoxType == TEXTBOX_TYPE_9) || + (msgCtx->textBoxType == TEXTBOX_TYPE_B) || (msgCtx->unk11F0C == 3)) { + msgCtx->textDrawPos = msgCtx->decodedTextLen; + } + msgCtx->unk120C8 = msgCtx->unk120CE; + msgCtx->unk120CA = msgCtx->unk120D0; + msgCtx->unk120CC = msgCtx->unk120D2; + break; + } else if (curChar == 0x16) { + // Substitute the player name control character for the file's player name. + for (playerNameLen = ARRAY_COUNT(gSaveContext.save.saveInfo.playerData.playerName); playerNameLen > 0; + playerNameLen--) { + if (gSaveContext.save.saveInfo.playerData.playerName[playerNameLen - 1] != 0x3E) { + break; + } + } + + for (i = 0; i < playerNameLen; i++) { + curChar = gSaveContext.save.saveInfo.playerData.playerName[i]; + if (curChar == 0x3E) { + curChar = ' '; + } else if (curChar == 0x40) { + curChar = '.'; + } else if (curChar == 0x3F) { + curChar = '-'; + } else if (curChar < 0xA) { + charOffset = curChar; + curChar = '0' + charOffset; + } else if (curChar < 0x24) { + charOffset = curChar; + curChar = 'A' - 10 + charOffset; + } else if (curChar < 0x3E) { + charOffset = curChar; + curChar = 'a' - 36 + charOffset; + } + if (curChar != ' ') { + Font_LoadCharNES(play, curChar, charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + } + msgCtx->decodedBuffer.schar[decodedBufPos] = curChar; + decodedBufPos++; + } + decodedBufPos--; + } else if (curChar == 0xC1) { + //! TODO: + 0x900 on the first one? + DmaMgr_SendRequest0(msgCtx->textboxSegment + 0x1000, SEGMENT_ROM_START(message_texture_static), 0x900); + DmaMgr_SendRequest0(msgCtx->textboxSegment + 0x1900, + (uintptr_t)SEGMENT_ROM_START(message_texture_static) + 0x900, 0x900); + spD0 = 2; + spC6 = 2; + msgCtx->unk12012 = msgCtx->textboxY + 8; + msgCtx->unk11F18 = 1; + msgCtx->unk12010 = XREG(47); + } else if (curChar == 0xC2) { + msgCtx->unk11F18 = 0; + msgCtx->choiceNum = 2; + } else if (curChar == 0xC3) { + msgCtx->unk11F18 = 0; + msgCtx->choiceNum = 3; + msgCtx->unk11FF8 = msgCtx->unk11FF8 + 0x16; + } else if (curChar == 0xC4) { + Message_GetTimerDigitsNES(((void)0, gSaveContext.timerCurTimes[curChar - 0xC4]), spA8); + + loadChar = false; + for (i = 0; i < 5; i++) { + if ((i == 1) || (spA8[i + 3] != '0')) { + loadChar = true; + } + if (loadChar) { + Message_LoadCharNES(play, spA8[i + 3], &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + } + } + decodedBufPos--; + } else if ((curChar == 0xC5) || (curChar == 0xC6) || (curChar == 0xC7) || (curChar == 0xC8) || + (curChar == 0xC9)) { + Message_GetTimerDigitsNES(((void)0, gSaveContext.timerCurTimes[curChar - 0xC4]), spA8); + + loadChar = false; + for (i = 0; i < 8; i++) { + if ((i == 4) || ((i != 2) && (i != 5) && (spA8[i] != '0'))) { + loadChar = true; + } + if (loadChar) { + Message_LoadCharNES(play, spA8[i], &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + } + } + decodedBufPos--; + } else if (curChar == 0xCA) { + digits[0] = 0; + timeInSeconds = TIME_TO_MINUTES_F(gSaveContext.save.time); + + digits[1] = timeInSeconds / 60.0f; + while (digits[1] >= 10) { + digits[0]++; + digits[1] -= 10; + } + + digits[2] = 0; + digits[3] = (s32)timeInSeconds % 60; + while (digits[3] >= 10) { + digits[2]++; + digits[3] -= 10; + } + + for (i = 0; i < 4; i++) { + Font_LoadCharNES(play, digits[i] + '0', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = digits[i] + '0'; + decodedBufPos++; + if (i == 1) { + Font_LoadCharNES(play, '"', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = 0x22; + decodedBufPos++; + } else if (i == 3) { + Font_LoadCharNES(play, 0x27, charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = 0x27; + } + } + spA4 += 6 * (16.0f * msgCtx->textCharScale); + } else if (curChar == 0xCB) { + digits[0] = digits[1] = digits[2] = 0; + digits[3] = Flags_GetAllTreasure(play); + + while (digits[3] >= 1000) { + digits[0]++; + digits[3] -= 1000; + } + while (digits[3] >= 100) { + digits[1]++; + digits[3] -= 100; + } + while (digits[3] >= 10) { + digits[2]++; + digits[3] -= 10; + } + + loadChar = false; + for (i = 0; i < 4; i++) { + if ((i == 3) || (digits[i] != 0)) { + loadChar = true; + } + if (loadChar) { + Font_LoadCharNES(play, digits[i] + '0', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = digits[i] + '0'; + decodedBufPos++; + spA4 += 16.0f * msgCtx->textCharScale; + } + } + decodedBufPos--; + } else if (curChar == 0xCC) { + decodedBufPos++; + msgCtx->unk120BE = spC6; + msgCtx->unk120C0 = decodedBufPos; + msgCtx->unk120C2 = 2; + msgCtx->bankRupeesSelected = 0; + msgCtx->unk120C4 = charTexIdx; + digits[0] = digits[1] = digits[2] = 0; + + for (i = 0; i < 3; i++) { + Message_LoadCharNES(play, digits[i] + '0', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + } + Message_LoadLocalizedRupeesNES(play, &decodedBufPos, &charTexIdx, &spA4); + } else if (curChar == 0xCD) { + digits[0] = digits[1] = 0; + digits[2] = msgCtx->bankRupeesSelected; + + while (digits[2] >= 100) { + digits[0]++; + digits[2] -= 100; + } + + while (digits[2] >= 10) { + digits[1]++; + digits[2] -= 10; + } + + loadChar = false; + for (i = 0; i < 3; i++) { + if ((i == 2) || (digits[i] != 0)) { + loadChar = true; + } + if (loadChar) { + Message_LoadCharNES(play, digits[i] + '0', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + } + } + Message_LoadRupeesNES(play, &decodedBufPos, &charTexIdx, &spA4, msgCtx->bankRupeesSelected); + } else if (curChar == 0xCE) { + digits[0] = digits[1] = digits[2] = 0; + digits[3] = msgCtx->bankRupees; + + while (digits[3] >= 1000) { + digits[0]++; + digits[3] -= 1000; + } + while (digits[3] >= 100) { + digits[1]++; + digits[3] -= 100; + } + while (digits[3] >= 10) { + digits[2]++; + digits[3] -= 10; + } + + loadChar = false; + for (i = 0; i < 4; i++) { + if ((i == 3) || (digits[i] != 0)) { + loadChar = true; + } + if (loadChar) { + Message_LoadCharNES(play, digits[i] + '0', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + } + } + Message_LoadRupeesNES(play, &decodedBufPos, &charTexIdx, &spA4, msgCtx->bankRupees); + } else if (curChar == 0xCF) { + Message_LoadTimeNES(play, curChar, &charTexIdx, &spA4, &decodedBufPos); + } else if (curChar == 0xC) { + digits[0] = digits[1] = 0; + digits[2] = gSaveContext.save.saveInfo.inventory.strayFairies[(void)0, gSaveContext.dungeonIndex]; + + while (digits[2] >= 100) { + digits[0]++; + digits[2] -= 100; + } + while (digits[2] >= 10) { + digits[1]++; + digits[2] -= 10; + } + + loadChar = false; + for (i = 0; i < 3; i++) { + if ((i == 2) || (digits[i] != 0)) { + loadChar = true; + } + if (loadChar) { + Message_LoadCharNES(play, digits[i] + '0', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + } + } + + if ((gSaveContext.save.saveInfo.inventory.strayFairies[(void)0, gSaveContext.dungeonIndex] == 1) || + (gSaveContext.save.saveInfo.inventory.strayFairies[(void)0, gSaveContext.dungeonIndex] == 21)) { + Message_LoadCharNES(play, 's', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + Message_LoadCharNES(play, 't', &charTexIdx, &spA4, decodedBufPos); + } else if ((gSaveContext.save.saveInfo.inventory.strayFairies[(void)0, gSaveContext.dungeonIndex] == 2) || + (gSaveContext.save.saveInfo.inventory.strayFairies[(void)0, gSaveContext.dungeonIndex] == 22)) { + Message_LoadCharNES(play, 'n', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + Message_LoadCharNES(play, 'd', &charTexIdx, &spA4, decodedBufPos); + } else if ((gSaveContext.save.saveInfo.inventory.strayFairies[(void)0, gSaveContext.dungeonIndex] == 3) || + (gSaveContext.save.saveInfo.inventory.strayFairies[(void)0, gSaveContext.dungeonIndex] == 23)) { + Message_LoadCharNES(play, 'r', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + Message_LoadCharNES(play, 'd', &charTexIdx, &spA4, decodedBufPos); + } else { + Message_LoadCharNES(play, 't', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + Message_LoadCharNES(play, 'h', &charTexIdx, &spA4, decodedBufPos); + } + } else if (curChar == 0xD) { + digits[0] = digits[1] = 0; + digits[2] = Inventory_GetSkullTokenCount(play->sceneId); + + while (digits[2] >= 100) { + digits[0]++; + digits[2] -= 100; + } + while (digits[2] >= 10) { + digits[1]++; + digits[2] -= 10; + } + + loadChar = false; + for (i = 0; i < 3; i++) { + if ((i == 2) || (digits[i] != 0)) { + loadChar = true; + } + if (loadChar) { + Message_LoadCharNES(play, digits[i] + '0', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + } + } + + if ((Inventory_GetSkullTokenCount(play->sceneId) == 1) || + (Inventory_GetSkullTokenCount(play->sceneId) == 21)) { + Message_LoadCharNES(play, 's', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + Message_LoadCharNES(play, 't', &charTexIdx, &spA4, decodedBufPos); + } else if ((Inventory_GetSkullTokenCount(play->sceneId) == 2) || + (Inventory_GetSkullTokenCount(play->sceneId) == 22)) { + Message_LoadCharNES(play, 'n', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + Message_LoadCharNES(play, 'd', &charTexIdx, &spA4, decodedBufPos); + } else if ((Inventory_GetSkullTokenCount(play->sceneId) == 3) || + (Inventory_GetSkullTokenCount(play->sceneId) == 23)) { + Message_LoadCharNES(play, 'r', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + Message_LoadCharNES(play, 'd', &charTexIdx, &spA4, decodedBufPos); + } else { + Message_LoadCharNES(play, 't', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + Message_LoadCharNES(play, 'h', &charTexIdx, &spA4, decodedBufPos); + } + } else if (curChar == 0xE) { + digits[0] = 0; + digits[1] = gSaveContext.minigameScore; + + while (digits[1] >= 10) { + digits[0]++; + digits[1] -= 10; + } + + for (i = 0; i < 2; i++) { + if ((i == 1) || (digits[i] != 0)) { + Message_LoadCharNES(play, digits[i] + '0', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + } + } + + decodedBufPos--; + } else if (curChar == 0xF) { + digits[0] = digits[1] = digits[2] = 0; + digits[3] = gSaveContext.minigameScore; + + while (digits[3] >= 1000) { + digits[0]++; + digits[3] -= 1000; + } + while (digits[3] >= 100) { + digits[1]++; + digits[3] -= 100; + } + while (digits[3] >= 10) { + digits[2]++; + digits[3] -= 10; + } + + loadChar = false; + for (i = 0; i < 4; i++) { + if ((i == 3) || (digits[i] != 0)) { + loadChar = true; + } + if (loadChar) { + Message_LoadCharNES(play, digits[i] + '0', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + } + } + decodedBufPos--; + } else if (curChar == 0xD0) { + decodedBufPos++; + msgCtx->unk120BE = spC6; + msgCtx->unk120C0 = decodedBufPos; + msgCtx->unk120C2 = 0; + msgCtx->bankRupeesSelected = 0; + msgCtx->unk120C4 = charTexIdx; + digits[0] = digits[1] = digits[2] = 0; + for (i = 0; i < 2; i++) { + Message_LoadCharNES(play, digits[i] + '0', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + } + Message_LoadPluralRupeesNES(play, &decodedBufPos, &charTexIdx, &spA4); + } else if (curChar == 0xD1) { + decodedBufPos++; + msgCtx->unk120BE = spC6; + msgCtx->unk120C0 = decodedBufPos; + msgCtx->unk120C2 = 0; + msgCtx->bankRupeesSelected = 0; + msgCtx->unk120C4 = charTexIdx; + + for (i = 0; i < 5; i++) { + msgCtx->unk12054[i] = 1; + Message_LoadCharNES(play, '1', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + } + decodedBufPos--; + } else if (curChar == 0xD3) { + if (gSaveContext.save.timeSpeedOffset == 18) { + var_s2_9 = 0; + } else if (gSaveContext.save.timeSpeedOffset == 0) { + var_s2_9 = 1; + } else { + var_s2_9 = 2; + } + + for (i = 0; i < 4; i++) { + msgCtx->decodedBuffer.schar[decodedBufPos] = D_801D08D8[var_s2_9][i]; + Font_LoadCharNES(play, D_801D08D8[var_s2_9][i], charTexIdx); + decodedBufPos++; + charTexIdx += FONT_CHAR_TEX_SIZE; + } + decodedBufPos--; + spA4 += 3.0f * (16.0f * msgCtx->textCharScale); + msgCtx->choiceIndex = var_s2_9; + } else if (curChar == 0xD4) { + Message_LoadOwlWarpTextNES(play, &charTexIdx, &spA4, &decodedBufPos); + } else if (curChar == 0xD5) { + decodedBufPos++; + msgCtx->unk120BE = spC6; + msgCtx->unk120C0 = decodedBufPos; + msgCtx->unk120C2 = 0; + msgCtx->bankRupeesSelected = 0; + msgCtx->unk120C4 = charTexIdx; + + for (i = 0; i < 3; i++) { + msgCtx->unk12054[i] = 1; + Font_LoadCharNES(play, '1', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = '1'; + spA4 += 16.0f * msgCtx->textCharScale; + decodedBufPos++; + } + decodedBufPos--; + } else if (curChar == 0xD6) { + for (i = 0; i < 6; i++) { + msgCtx->decodedBuffer.schar[decodedBufPos] = + (s8)D_801D08E4[((void)0, gSaveContext.save.saveInfo.spiderHouseMaskOrder[i])]; + decodedBufPos++; + Message_LoadCharNES(play, i + '1', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + } + msgCtx->decodedBuffer.schar[decodedBufPos] = 0; + } else if ((curChar >= 0xD7) && (curChar < 0xDB)) { + digits[0] = digits[1] = 0; + digits[2] = 15 - gSaveContext.save.saveInfo.inventory.strayFairies[curChar - 0xD7]; + + while (digits[2] >= 100) { + digits[0]++; + digits[2] -= 100; + } + while (digits[2] >= 10) { + digits[1]++; + digits[2] -= 10; + } + + loadChar = false; + for (i = 0; i < 3; i++) { + if ((i == 2) || (digits[i] != 0)) { + loadChar = true; + } + if (loadChar) { + Font_LoadCharNES(play, digits[i] + '0', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = digits[i] + '0'; + decodedBufPos++; + spA4 += 16.0f * msgCtx->textCharScale; + } + } + } else if (curChar == 0xDB) { + digits[0] = digits[1] = digits[2] = 0; + digits[3] = gSaveContext.minigameScore; + + while (digits[3] >= 1000) { + digits[0]++; + digits[3] -= 1000; + } + while (digits[3] >= 100) { + digits[1]++; + digits[3] -= 100; + } + while (digits[3] >= 10) { + digits[2]++; + digits[3] -= 10; + } + + loadChar = false; + for (i = 0; i < 4; i++) { + if ((i == 3) || (digits[i] != 0)) { + loadChar = true; + } + if (loadChar) { + Font_LoadCharNES(play, digits[i] + '0', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = digits[i] + '0'; + decodedBufPos++; + spA4 += 16.0f * msgCtx->textCharScale; + } + } + decodedBufPos--; + } else if ((curChar == 0xDC) || (curChar == 0xDD)) { + if (curChar == 0xDC) { + digits[0] = gSaveContext.save.saveInfo.lotteryCodes[CURRENT_DAY - 1][0]; + digits[1] = gSaveContext.save.saveInfo.lotteryCodes[CURRENT_DAY - 1][1]; + digits[2] = gSaveContext.save.saveInfo.lotteryCodes[CURRENT_DAY - 1][2]; + } else { + digits[0] = (HS_GET_LOTTERY_CODE_GUESS() & 0xF00) >> 8; + digits[1] = (HS_GET_LOTTERY_CODE_GUESS() & 0xF0) >> 4; + digits[2] = HS_GET_LOTTERY_CODE_GUESS() & 0xF; + } + + for (i = 0; i < 3; i++) { + Font_LoadCharNES(play, digits[i] + '0', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = digits[i] + '0'; + decodedBufPos++; + spA4 += 16.0f * msgCtx->textCharScale; + } + decodedBufPos--; + } else if (curChar == 0xDE) { + digits[0] = digits[1] = digits[2] = 0; + digits[3] = gItemPrices[GET_CUR_FORM_BTN_ITEM(player->heldItemButton)]; + + while (digits[3] >= 1000) { + digits[0]++; + digits[3] -= 1000; + } + while (digits[3] >= 100) { + digits[1]++; + digits[3] -= 100; + } + while (digits[3] >= 10) { + digits[2]++; + digits[3] -= 10; + } + + loadChar = false; + for (i = 0; i < 4; i++) { + if ((i == 3) || (digits[i] != 0)) { + loadChar = true; + } + if (loadChar) { + Font_LoadCharNES(play, digits[i] + '0', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = digits[i] + '0'; + decodedBufPos++; + spA4 += 16.0f * msgCtx->textCharScale; + } + } + Message_LoadPluralRupeesNES(play, &decodedBufPos, &charTexIdx, &spA4); + } else if (curChar == 0xDF) { + for (i = 0; i < 5; i++) { + digits[i] = gSaveContext.save.saveInfo.bomberCode[i]; + Font_LoadCharNES(play, digits[i] + '0', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = digits[i] + '0'; + decodedBufPos++; + spA4 += 16.0f * msgCtx->textCharScale; + } + decodedBufPos--; + } else if ((curChar >= 0xE1) && (curChar < 0xE7)) { + msgCtx->decodedBuffer.schar[decodedBufPos] = + D_801D08E4[((void)0, gSaveContext.save.saveInfo.spiderHouseMaskOrder[(s16)(curChar - 0xE1)])]; + temp_s2_2 = sMaskCodeTextLengthENG[( + (void)0, gSaveContext.save.saveInfo.spiderHouseMaskOrder[(s16)(curChar - 0xE1)])]; + decodedBufPos++; + + for (i = 0; i < temp_s2_2; i++) { + Message_LoadCharNES( + play, + sMaskCodeTextENG[((void)0, gSaveContext.save.saveInfo.spiderHouseMaskOrder[(s16)(curChar - 0xE1)])] + [i], + &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + } + + msgCtx->decodedBuffer.schar[decodedBufPos] = 0; + } else if (curChar == 0xE7) { + timeToMoonCrash = TIME_UNTIL_MOON_CRASH; + digits[0] = 0; + digits[1] = TIME_TO_HOURS_F_ALT(timeToMoonCrash); + + while (digits[1] >= 10) { + digits[0]++; + digits[1] -= 10; + } + + loadChar = false; + for (i = 0; i < 2; i++) { + if ((i == 1) || (digits[i] != 0)) { + loadChar = true; + } + if (loadChar) { + Message_LoadCharNES(play, digits[i] + '0', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + } + } + msgCtx->decodedBuffer.schar[decodedBufPos] = ' '; + decodedBufPos++; + Message_LoadCharNES(play, 'h', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + Message_LoadCharNES(play, 'o', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + Message_LoadCharNES(play, 'u', &charTexIdx, &spA4, decodedBufPos); + decodedBufPos++; + Message_LoadCharNES(play, 'r', &charTexIdx, &spA4, decodedBufPos); + if ((digits[0] != 0) || (digits[1] != 1)) { + decodedBufPos++; + Message_LoadCharNES(play, 's', &charTexIdx, &spA4, decodedBufPos); + } + } else if (curChar == 0xE8) { + Message_LoadTimeNES(play, curChar, &charTexIdx, &spA4, &decodedBufPos); + + } else if ((curChar == 0xF0) || (curChar == 0xF1) || (curChar == 0xF2) || (curChar == 0xF8)) { + if (curChar == 0xF8) { + value = (s32)HS_GET_HIGH_SCORE_3_LOWER(); + } else { + value = HIGH_SCORE(curChar - 0xF0); + } + if (curChar == 0xF2) { + if (LINK_AGE_IN_YEARS == YEARS_CHILD) { + value &= 0x7F; + } else { + value = (s16)((HIGH_SCORE((u8)font->msgBuf.schar[msgCtx->msgBufPos]) & 0xFF000000) >> 0x18) & 0x7F; + } + } + digits[3] = value; + digits[0] = digits[1] = digits[2] = 0; + + while (digits[3] >= 1000) { + digits[0]++; + digits[3] -= 1000; + } + while (digits[3] >= 100) { + digits[1]++; + digits[3] -= 100; + } + while (digits[3] >= 10) { + digits[2]++; + digits[3] -= 10; + } + + loadChar = false; + for (i = 0; i < 4; i++) { + if ((i == 3) || (digits[i] != 0)) { + loadChar = true; + } + if (loadChar) { + Font_LoadCharNES(play, digits[i] + '0', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = digits[i] + '0'; + decodedBufPos++; + spA4 += 16.0f * msgCtx->textCharScale; + } + } + decodedBufPos--; + } else if ((curChar == 0xF7) || (curChar == 0xF9) || (curChar == 0xFA) || (curChar == 0xFB) || + (curChar == 0xFC)) { + var_fs0 = 8.0f; + if (curChar == 0xF7) { + Message_GetTimerDigitsNES(GET_HIGH_SCORE(HS_UNK_1), spA8); + } else if (curChar == 0xF9) { + Message_GetTimerDigitsNES(GET_HIGH_SCORE(HS_HORSE_BACK_BALLOON), spA8); + } else { + Message_GetTimerDigitsNES( + ((void)0, gSaveContext.save.saveInfo.dekuPlaygroundHighScores[curChar - 0xFA]), spA8); + } + + loadChar = false; + for (i = 0; i < 8; i++) { + if ((i == 4) || ((i != 2) && (i != 5) && (spA8[i] != '\0'))) { + loadChar = true; + } + if (loadChar) { + Font_LoadCharNES(play, spA8[i], charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = spA8[i]; + decodedBufPos++; + } else { + var_fs0 -= 1.0f; + } + } + spA4 += var_fs0 * (16.0f * msgCtx->textCharScale); + decodedBufPos--; + } else if ((curChar == 0xF3) || (curChar == 0xF4) || (curChar == 0xF5)) { + value = HIGH_SCORE(curChar - 0xF3 + HS_BOAT_ARCHERY); + digits[0] = digits[1] = digits[2] = 0; + digits[3] = value; + + while (digits[3] >= 60) { + digits[1]++; + if (digits[1] >= 10) { + digits[0]++; + digits[1] -= 10; + } + digits[3] -= 60; + } + while (digits[3] >= 10) { + digits[2]++; + digits[3] -= 10; + } + + for (i = 0; i < 4; i++) { + Font_LoadCharNES(play, digits[i] + '0', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = digits[i] + '0'; + decodedBufPos++; + if (i == 1) { + Font_LoadCharNES(play, '"', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = '"'; + decodedBufPos++; + } else if (i == 3) { + Font_LoadCharNES(play, 0x27, charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = 0x27; + } + } + spA4 += 4.0f * (16.0f * msgCtx->textCharScale); + } else if (curChar == 0xF6) { + digits[0] = digits[1] = digits[2] = 0; + digits[3] = HS_GET_TOWN_SHOOTING_GALLERY_HIGH_SCORE(); + + while (digits[3] >= 1000) { + digits[0]++; + digits[3] -= 1000; + } + while (digits[3] >= 100) { + digits[1]++; + digits[3] -= 100; + } + while (digits[3] >= 10) { + digits[2]++; + digits[3] -= 10; + } + + loadChar = false; + for (i = 0; i < 4; i++) { + if ((i == 3) || (digits[i] != 0)) { + loadChar = true; + } + if (loadChar) { + Font_LoadCharNES(play, digits[i] + '0', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = digits[i] + '0'; + decodedBufPos++; + spA4 += 16.0f * msgCtx->textCharScale; + } + } + decodedBufPos--; + } else if ((curChar == 0xFD) || (curChar == 0xFE) || (curChar == 0xFF)) { + for (playerNameLen = 8; playerNameLen > 0; playerNameLen--) { + if (gSaveContext.save.saveInfo.inventory + .dekuPlaygroundPlayerName[(s16)(curChar - 0xFD)][playerNameLen - 1] != 0x3E) { + break; + } + } + + for (i = 0; i < playerNameLen; i++) { + ptr = &font->fontBuf[((void)0, gSaveContext.save.saveInfo.inventory + .dekuPlaygroundPlayerName[(s16)(curChar - 0xFD)][i]) * + FONT_CHAR_TEX_SIZE]; + msgCtx->decodedBuffer.schar[decodedBufPos + i] = 0xFD; + + for (var_v1_3 = 0; var_v1_3 < FONT_CHAR_TEX_SIZE; var_v1_3 += 4) { + font->charBuf[font->unk_11D88][charTexIdx + var_v1_3 + 0] = ptr[var_v1_3 + 0]; + font->charBuf[font->unk_11D88][charTexIdx + var_v1_3 + 1] = ptr[var_v1_3 + 1]; + font->charBuf[font->unk_11D88][charTexIdx + var_v1_3 + 2] = ptr[var_v1_3 + 2]; + font->charBuf[font->unk_11D88][charTexIdx + var_v1_3 + 3] = ptr[var_v1_3 + 3]; + } + charTexIdx += FONT_CHAR_TEX_SIZE; + } + decodedBufPos += playerNameLen - 1; + spA4 += playerNameLen * (16.0f * msgCtx->textCharScale); + } else if (curChar == 0xB) { + digits[0] = digits[1] = digits[2] = 0; + digits[3] = HS_GET_BOAT_ARCHERY_HIGH_SCORE(); + + while (digits[3] >= 1000) { + digits[0]++; + digits[3] -= 1000; + } + while (digits[3] >= 100) { + digits[1]++; + digits[3] -= 100; + } + while (digits[3] >= 10) { + digits[2]++; + digits[3] -= 10; + } + + loadChar = false; + for (i = 0; i < 4; i++) { + if ((i == 3) || (digits[i] != 0)) { + loadChar = true; + } + if (loadChar) { + Font_LoadCharNES(play, digits[i] + '0', charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + msgCtx->decodedBuffer.schar[decodedBufPos] = digits[i] + '0'; + decodedBufPos++; + spA4 += 16.0f * msgCtx->textCharScale; + } + } + decodedBufPos--; + } else if (curChar == 0x14) { + decodedBufPos--; + for (i = 0; i < font->msgBuf.schar[msgCtx->msgBufPos + 1]; i++) { + msgCtx->decodedBuffer.schar[++decodedBufPos] = ' '; + spA4 += 6.0f; + } + msgCtx->msgBufPos++; + } else if ((curChar == 0x13) || (curChar == 0x11)) { + msgCtx->unk11F1A[spC6] = 0; + if (msgCtx->unk11F18 != 0) { + msgCtx->unk11F1A[spC6] = ((msgCtx->textCharScale * 16.0f * 16.0f) - spA4) * 0.5f; + } + spC6++; + spA4 = 0.0f; + if (curChar == 0x11) { + spD0++; + } + } else if ((curChar == 0x17) || (curChar == 0x18) || (curChar == 0x1A)) { + // pass + } else if (curChar == 0xA) { + decodedBufPos++; + } else if (curChar == 0x1C) { + msgCtx->textFade = true; + msgCtx->decodedBuffer.schar[++decodedBufPos] = font->msgBuf.schar[++msgCtx->msgBufPos]; + msgCtx->decodedBuffer.schar[++decodedBufPos] = font->msgBuf.schar[++msgCtx->msgBufPos]; + } else if (curChar == 0x1E) { + msgCtx->decodedBuffer.schar[++decodedBufPos] = font->msgBuf.schar[++msgCtx->msgBufPos]; + msgCtx->decodedBuffer.schar[++decodedBufPos] = font->msgBuf.schar[++msgCtx->msgBufPos]; + if (msgCtx->textboxSkipped || (msgCtx->textBoxType == TEXTBOX_TYPE_1) || + (msgCtx->textBoxType == TEXTBOX_TYPE_3) || (msgCtx->textBoxType == TEXTBOX_TYPE_6) || + (msgCtx->textBoxType == TEXTBOX_TYPE_8) || (msgCtx->textBoxType == TEXTBOX_TYPE_9) || + (msgCtx->textBoxType == TEXTBOX_TYPE_B) || (msgCtx->unk11F0C == 3)) { + Audio_PlaySfx((msgCtx->decodedBuffer.schar[decodedBufPos - 1] << 8) | + msgCtx->decodedBuffer.schar[decodedBufPos]); + } + } else if (curChar == 0x1F) { + msgCtx->decodedBuffer.schar[++decodedBufPos] = font->msgBuf.schar[++msgCtx->msgBufPos]; + msgCtx->decodedBuffer.schar[++decodedBufPos] = font->msgBuf.schar[++msgCtx->msgBufPos]; + } else if ((curChar != 0x20) && (curChar >= 9)) { + Font_LoadCharNES(play, curChar, charTexIdx); + charTexIdx += FONT_CHAR_TEX_SIZE; + spA4 += sNESFontWidths[curChar - ' '] * msgCtx->textCharScale; + } else if (curChar == 0x20) { + spA4 += 6.0f; + } + decodedBufPos++; + msgCtx->msgBufPos++; + } +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_message_nes/Message_DecodeNES.s") +#endif diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index d54b83753..d7350076d 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2838,14 +2838,14 @@ 0x8014995C:("Message_DrawTextChar",), 0x80149C18:("func_80149C18",), 0x80149EBC:("Message_FindMessage",), - 0x80149F74:("func_80149F74",), + 0x80149F74:("Message_DrawItemIcon",), 0x8014AAD0:("Message_HandleOcarina",), 0x8014ADBC:("func_8014ADBC",), 0x8014C70C:("Message_LoadItemIcon",), 0x8014CC14:("Message_LoadChar",), 0x8014CCB4:("func_8014CCB4",), 0x8014CDF0:("func_8014CDF0",), - 0x8014CFDC:("func_8014CFDC",), + 0x8014CFDC:("Message_SetupLoadItemIcon",), 0x8014D304:("func_8014D304",), 0x8014D62C:("func_8014D62C",), 0x8014D7B4:("func_8014D7B4",), @@ -2881,9 +2881,9 @@ 0x80158D98:("Message_LoadRupeesNES",), 0x80158FB0:("Message_LoadTimeNES",), 0x8015926C:("Message_LoadOwlWarpTextNES",), - 0x80159438:("func_80159438",), - 0x8015966C:("func_8015966C",), - 0x8015B198:("func_8015B198",), + 0x80159438:("Message_GetTimerDigitsNES",), + 0x8015966C:("Message_DrawTextNES",), + 0x8015B198:("Message_DecodeNES",), 0x8015E750:("Message_FindCreditsMessage",), 0x8015E7EC:("Message_DrawTextCredits",), 0x8015F8A8:("Message_DecodeCredits",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 90edb9bf5..f5905b769 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -2058,10 +2058,10 @@ 0x801D045A:("D_801D045A","UNK_TYPE1","",0x1), 0x801D0462:("D_801D0462","UNK_TYPE1","",0x1), 0x801D0468:("D_801D0468","UNK_TYPE1","",0x1), - 0x801D0470:("D_801D0470","UNK_TYPE1","",0x1), - 0x801D06F0:("D_801D06F0","char","[]",0x18), + 0x801D0470:("sNESFontWidths","UNK_TYPE1","",0x1), + 0x801D06F0:("sRupeesTextLocalization","char","[]",0x18), 0x801D0708:("D_801D0708","char","[]",1), - 0x801D0710:("D_801D0710","UNK_TYPE1","",0x1), + 0x801D0710:("sRupeesTextLength","UNK_TYPE1","",0x1), 0x801D0714:("D_801D0714","char","[]",0x1), 0x801D0724:("D_801D0724","char","[]",0x1), 0x801D0730:("D_801D0730","char","[]",0x1), @@ -2083,14 +2083,13 @@ 0x801D07DC:("D_801D07DC","UNK_TYPE1","",0x1), 0x801D080C:("D_801D080C","UNK_TYPE1","",0x1), 0x801D083C:("D_801D083C","UNK_TYPE1","",0x1), - 0x801D086C:("D_801D086C","UNK_TYPE1","",0x1), - 0x801D0890:("D_801D0890","UNK_TYPE1","",0x1), + 0x801D086C:("D_801D086C","UNK_TYPE1","",0x30), 0x801D089C:("D_801D089C","UNK_TYPE1","",0x1), 0x801D08CC:("D_801D08CC","UNK_TYPE1","",0x1), 0x801D08D8:("D_801D08D8","UNK_TYPE1","",0x1), 0x801D08E4:("D_801D08E4","UNK_TYPE1","",0x1), - 0x801D08E8:("D_801D08E8","UNK_TYPE1","",0x1), - 0x801D0900:("D_801D0900","UNK_TYPE1","",0x1), + 0x801D08E8:("sMaskCodeTextENG","UNK_TYPE1","",0x1), + 0x801D0900:("sMaskCodeTextLengthENG","UNK_TYPE1","",0x1), 0x801D0B50:("Player_InitVars","ActorInit","",0x20), 0x801D0B70:("gKaleidoMgrOverlayTable","KaleidoMgrOverlay","",0x38), 0x801D0BA8:("sKaleidoAreaPtr","void*","",0x4), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 767d81514..caaa33d73 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2350,16 +2350,16 @@ asm/non_matchings/code/z_message/func_801491DC.s,func_801491DC,0x801491DC,0x9E asm/non_matchings/code/z_message/func_80149454.s,func_80149454,0x80149454,0x9D asm/non_matchings/code/z_message/func_801496C8.s,func_801496C8,0x801496C8,0xA5 asm/non_matchings/code/z_message/func_8014995C.s,func_8014995C,0x8014995C,0xAF -asm/non_matchings/code/z_message/func_80149C18.s,func_80149C18,0x80149C18,0xA9 +asm/non_matchings/code/z_message/Message_DrawItemIcon.s,Message_DrawItemIcon,0x80149C18,0xA9 asm/non_matchings/code/z_message/Message_FindMessage.s,Message_FindMessage,0x80149EBC,0x2E -asm/non_matchings/code/z_message/func_80149F74.s,func_80149F74,0x80149F74,0x2D7 +asm/non_matchings/code/z_message/Message_DrawItemIcon.s,Message_DrawItemIcon,0x80149F74,0x2D7 asm/non_matchings/code/z_message/func_8014AAD0.s,func_8014AAD0,0x8014AAD0,0xBB asm/non_matchings/code/z_message/func_8014ADBC.s,func_8014ADBC,0x8014ADBC,0x654 asm/non_matchings/code/z_message/func_8014C70C.s,func_8014C70C,0x8014C70C,0x142 asm/non_matchings/code/z_message/Message_LoadChar.s,Message_LoadChar,0x8014CC14,0x28 asm/non_matchings/code/z_message/func_8014CCB4.s,func_8014CCB4,0x8014CCB4,0x4F asm/non_matchings/code/z_message/func_8014CDF0.s,func_8014CDF0,0x8014CDF0,0x7B -asm/non_matchings/code/z_message/func_8014CFDC.s,func_8014CFDC,0x8014CFDC,0xCA +asm/non_matchings/code/z_message/Message_SetupLoadItemIcon.s,Message_SetupLoadItemIcon,0x8014CFDC,0xCA asm/non_matchings/code/z_message/func_8014D304.s,func_8014D304,0x8014D304,0xCA asm/non_matchings/code/z_message/func_8014D62C.s,func_8014D62C,0x8014D62C,0x62 asm/non_matchings/code/z_message/func_8014D7B4.s,func_8014D7B4,0x8014D7B4,0xCB4 From 0fdd63a350c47b5da87a58f00855bc95b6a32b47 Mon Sep 17 00:00:00 2001 From: Zach North Date: Wed, 27 Sep 2023 23:19:28 -0400 Subject: [PATCH 3/9] Document object_mk (#1389) * Updated object_mk animation, limb, and skeleton names * Updated object_mk texture and DList names * Added comment to object_mk.xml * Remove "ing" from Anim names Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * Update z_en_mk.c to not use "ing" in names * Running formatter --------- Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> --- assets/xml/objects/object_mk.xml | 83 +++++++++++++------------ src/overlays/actors/ovl_En_Mk/z_en_mk.c | 12 ++-- src/overlays/actors/ovl_En_Mk/z_en_mk.h | 4 +- 3 files changed, 50 insertions(+), 49 deletions(-) diff --git a/assets/xml/objects/object_mk.xml b/assets/xml/objects/object_mk.xml index 087fcc9e0..457eadf28 100644 --- a/assets/xml/objects/object_mk.xml +++ b/assets/xml/objects/object_mk.xml @@ -1,45 +1,46 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/overlays/actors/ovl_En_Mk/z_en_mk.c b/src/overlays/actors/ovl_En_Mk/z_en_mk.c index ac816517c..43f9a3d99 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.c @@ -57,8 +57,8 @@ static ColliderCylinderInit sCylinderInit = { s32 func_809592E0(EnMk* this, s16 index) { AnimationHeader* sAnimations[] = { - &object_mk_Anim_001C38, &object_mk_Anim_000438, &object_mk_Anim_0007D8, - &object_mk_Anim_0010F4, &object_mk_Anim_001964, + &gMarineResearcherIdleAnim, &gMarineResearcherHeadWaggleAnim, &gMarineResearcherYellAnim, + &gMarineResearcherShakeInFearAnim, &gMarineResearcherStrokeChinAnim, }; if (index == this->unk_27C) { @@ -82,8 +82,8 @@ void EnMk_Init(Actor* thisx, PlayState* play) { this->actor.terminalVelocity = -4.0f; this->actor.gravity = -1.0f; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &object_mk_Skel_006CA0, &object_mk_Anim_001C38, this->jointTable, - this->morphTable, OBJECT_MK_LIMB_MAX); + SkelAnime_InitFlex(play, &this->skelAnime, &gMarineResearcherSkel, &gMarineResearcherIdleAnim, this->jointTable, + this->morphTable, MARINE_RESEARCHER_LIMB_MAX); this->unk_27C = -1; func_809592E0(this, 0); @@ -463,7 +463,7 @@ void EnMk_Update(Actor* thisx, PlayState* play) { s32 EnMk_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnMk* this = THIS; - if (limbIndex == OBJECT_MK_LIMB_0B) { + if (limbIndex == MARINE_RESEARCHER_LIMB_HEAD) { rot->y -= this->unk_270.y; rot->z += this->unk_270.x; } @@ -475,7 +475,7 @@ Vec3f D_8095A2A0 = { 1000.0f, -100.0f, 0.0f }; void EnMk_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnMk* this = THIS; - if (limbIndex == OBJECT_MK_LIMB_0B) { + if (limbIndex == MARINE_RESEARCHER_LIMB_HEAD) { Matrix_MultVec3f(&D_8095A2A0, &this->actor.focus.pos); } } diff --git a/src/overlays/actors/ovl_En_Mk/z_en_mk.h b/src/overlays/actors/ovl_En_Mk/z_en_mk.h index 518b0406d..9d32e9374 100644 --- a/src/overlays/actors/ovl_En_Mk/z_en_mk.h +++ b/src/overlays/actors/ovl_En_Mk/z_en_mk.h @@ -12,8 +12,8 @@ typedef struct EnMk { /* 0x000 */ Actor actor; /* 0x144 */ ColliderCylinder collider; /* 0x190 */ SkelAnime skelAnime; - /* 0x1D4 */ Vec3s jointTable[OBJECT_MK_LIMB_MAX]; - /* 0x222 */ Vec3s morphTable[OBJECT_MK_LIMB_MAX]; + /* 0x1D4 */ Vec3s jointTable[MARINE_RESEARCHER_LIMB_MAX]; + /* 0x222 */ Vec3s morphTable[MARINE_RESEARCHER_LIMB_MAX]; /* 0x270 */ Vec3s unk_270; /* 0x276 */ s16 csIdList[2]; /* 0x27A */ u16 unk_27A; From 408a1bba5d879dd43ba40c279c0277c9d5bf78ac Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Fri, 29 Sep 2023 12:58:00 +1000 Subject: [PATCH 4/9] Player Docs: Initial framework for "Action Change Lists" (#1397) * copy fig docs * adjust wording * another fix * fix bool * PR Suggestion --- .../actors/ovl_player_actor/z_player.c | 408 +++++++++++++----- tools/disasm/functions.txt | 32 +- tools/disasm/variables.txt | 26 +- 3 files changed, 318 insertions(+), 148 deletions(-) diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 22fca02c8..8c1de93e5 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -233,21 +233,21 @@ void Player_InitItemAction_SpawnExplosive(PlayState* play, Player* this); void Player_InitItemAction_SpawnHookshot(PlayState* play, Player* this); void Player_InitItemAction_5(PlayState* play, Player* this); -s32 func_80839518(Player* this, PlayState* play); -s32 func_808365DC(Player* this, PlayState* play); -s32 func_8083D23C(Player* this, PlayState* play); -s32 func_8083CCB4(Player* this, PlayState* play); -s32 func_808391D8(Player* this, PlayState* play); -s32 func_8083DFC4(Player* this, PlayState* play); -s32 func_8083A114(Player* this, PlayState* play); -s32 func_80848570(Player* this, PlayState* play); -s32 func_8083A580(Player* this, PlayState* play); -s32 func_8083D78C(Player* this, PlayState* play); -s32 func_80839B18(Player* this, PlayState* play); -s32 func_8083A274(Player* this, PlayState* play); -s32 func_80834DFC(Player* this, PlayState* play); -s32 func_80838A90(Player* this, PlayState* play); -s32 func_8083A0CC(Player* this, PlayState* play); +s32 Player_ActionChange_0(Player* this, PlayState* play); +s32 Player_ActionChange_1(Player* this, PlayState* play); +s32 Player_ActionChange_2(Player* this, PlayState* play); +s32 Player_ActionChange_3(Player* this, PlayState* play); +s32 Player_ActionChange_4(Player* this, PlayState* play); +s32 Player_ActionChange_5(Player* this, PlayState* play); +s32 Player_ActionChange_6(Player* this, PlayState* play); +s32 Player_ActionChange_7(Player* this, PlayState* play); +s32 Player_ActionChange_8(Player* this, PlayState* play); +s32 Player_ActionChange_9(Player* this, PlayState* play); +s32 Player_ActionChange_10(Player* this, PlayState* play); +s32 Player_ActionChange_11(Player* this, PlayState* play); +s32 Player_ActionChange_12(Player* this, PlayState* play); +s32 Player_ActionChange_13(Player* this, PlayState* play); +s32 Player_ActionChange_14(Player* this, PlayState* play); /* Init Mode functions */ void Player_InitMode_0(PlayState* play, Player* this); @@ -4817,37 +4817,203 @@ s32 Player_GetMovementSpeedAndYaw(Player* this, f32* outSpeedTarget, s16* outYaw return false; } - *outYawTarget += Camera_GetInputDirYaw(play->cameraPtrs[play->activeCamId]); + *outYawTarget += Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)); return true; } +typedef enum ActionChangeIndex { + /* 0x0 */ PLAYER_ACTION_CHG_0, + /* 0x1 */ PLAYER_ACTION_CHG_1, + /* 0x2 */ PLAYER_ACTION_CHG_2, + /* 0x3 */ PLAYER_ACTION_CHG_3, + /* 0x4 */ PLAYER_ACTION_CHG_4, + /* 0x5 */ PLAYER_ACTION_CHG_5, + /* 0x6 */ PLAYER_ACTION_CHG_6, + /* 0x7 */ PLAYER_ACTION_CHG_7, + /* 0x8 */ PLAYER_ACTION_CHG_8, + /* 0x9 */ PLAYER_ACTION_CHG_9, + /* 0xA */ PLAYER_ACTION_CHG_10, + /* 0xB */ PLAYER_ACTION_CHG_11, + /* 0xC */ PLAYER_ACTION_CHG_12, + /* 0xD */ PLAYER_ACTION_CHG_13, + /* 0xE */ PLAYER_ACTION_CHG_14, + /* 0xF */ PLAYER_ACTION_CHG_MAX +} ActionChangeIndex; + /** - * The values of following arrays are used as indices for the `D_8085D054` array. + * The values of following arrays are used as indices for the `sPlayerActionChangeFuncs` array. * Each index correspond to a function which will be called sequentially until any of them return `true`. * Negative marks the end of the array. */ -s8 D_8085CFE4[] = { 13, 2, 4, 9, 10, 11, 8, -7 }; -s8 D_8085CFEC[] = { 13, 1, 2, 5, 3, 4, 9, 10, 11, 7, 8, -6 }; -s8 D_8085CFF8[] = { 13, 1, 2, 3, 4, 9, 10, 11, 8, 7, -6 }; -s8 D_8085D004[] = { 13, 2, 4, 9, 10, 11, 8, -7 }; -s8 D_8085D00C[] = { 13, 2, 4, 9, 10, 11, 12, 8, -7 }; -s8 D_8085D018[] = { -7 }; -s8 D_8085D01C[] = { 0, 11, 1, 2, 3, 5, 4, 9, 8, 7, -6 }; -s8 D_8085D028[] = { 0, 11, 1, 2, 3, 12, 5, 4, 9, 8, 7, -6 }; -s8 D_8085D034[] = { 13, 1, 2, 3, 12, 5, 4, 9, 10, 11, 8, 7, -6 }; -s8 D_8085D044[] = { 10, 8, -7 }; -s8 D_8085D048[] = { 0, 12, 5, 4, -14 }; -s8 D_8085D050[] = { 13, 2, -4 }; - -s32 (*D_8085D054[])(Player*, PlayState*) = { - func_80839518, func_808365DC, func_8083D23C, func_8083CCB4, func_808391D8, - func_8083DFC4, func_8083A114, func_80848570, func_8083A580, func_8083D78C, - func_80839B18, func_8083A274, func_80834DFC, func_80838A90, func_8083A0CC, +s8 sPlayerActionChangeList1[] = { + /* 0 */ PLAYER_ACTION_CHG_13, + /* 1 */ PLAYER_ACTION_CHG_2, + /* 2 */ PLAYER_ACTION_CHG_4, + /* 3 */ PLAYER_ACTION_CHG_9, + /* 4 */ PLAYER_ACTION_CHG_10, + /* 5 */ PLAYER_ACTION_CHG_11, + /* 6 */ PLAYER_ACTION_CHG_8, + /* 7 */ -PLAYER_ACTION_CHG_7, }; -s32 func_80833058(PlayState* play, Player* this, s8* arg2, s32 arg3) { +s8 sPlayerActionChangeList2[] = { + /* 0 */ PLAYER_ACTION_CHG_13, + /* 1 */ PLAYER_ACTION_CHG_1, + /* 2 */ PLAYER_ACTION_CHG_2, + /* 3 */ PLAYER_ACTION_CHG_5, + /* 4 */ PLAYER_ACTION_CHG_3, + /* 5 */ PLAYER_ACTION_CHG_4, + /* 6 */ PLAYER_ACTION_CHG_9, + /* 7 */ PLAYER_ACTION_CHG_10, + /* 8 */ PLAYER_ACTION_CHG_11, + /* 9 */ PLAYER_ACTION_CHG_7, + /* 10 */ PLAYER_ACTION_CHG_8, + /* 11 */ -PLAYER_ACTION_CHG_6, +}; + +s8 sPlayerActionChangeList3[] = { + /* 0 */ PLAYER_ACTION_CHG_13, + /* 1 */ PLAYER_ACTION_CHG_1, + /* 2 */ PLAYER_ACTION_CHG_2, + /* 3 */ PLAYER_ACTION_CHG_3, + /* 4 */ PLAYER_ACTION_CHG_4, + /* 5 */ PLAYER_ACTION_CHG_9, + /* 6 */ PLAYER_ACTION_CHG_10, + /* 7 */ PLAYER_ACTION_CHG_11, + /* 8 */ PLAYER_ACTION_CHG_8, + /* 9 */ PLAYER_ACTION_CHG_7, + /* 10 */ -PLAYER_ACTION_CHG_6, +}; + +s8 sPlayerActionChangeList4[] = { + /* 0 */ PLAYER_ACTION_CHG_13, + /* 1 */ PLAYER_ACTION_CHG_2, + /* 2 */ PLAYER_ACTION_CHG_4, + /* 3 */ PLAYER_ACTION_CHG_9, + /* 4 */ PLAYER_ACTION_CHG_10, + /* 5 */ PLAYER_ACTION_CHG_11, + /* 6 */ PLAYER_ACTION_CHG_8, + /* 7 */ -PLAYER_ACTION_CHG_7, +}; + +s8 sPlayerActionChangeList5[] = { + /* 0 */ PLAYER_ACTION_CHG_13, + /* 1 */ PLAYER_ACTION_CHG_2, + /* 2 */ PLAYER_ACTION_CHG_4, + /* 3 */ PLAYER_ACTION_CHG_9, + /* 4 */ PLAYER_ACTION_CHG_10, + /* 5 */ PLAYER_ACTION_CHG_11, + /* 6 */ PLAYER_ACTION_CHG_12, + /* 7 */ PLAYER_ACTION_CHG_8, + /* 8 */ -PLAYER_ACTION_CHG_7, +}; + +s8 sPlayerActionChangeList6[] = { + /* 0 */ -PLAYER_ACTION_CHG_7, +}; + +s8 sPlayerActionChangeList7[] = { + /* 0 */ PLAYER_ACTION_CHG_0, + /* 1 */ PLAYER_ACTION_CHG_11, + /* 2 */ PLAYER_ACTION_CHG_1, + /* 3 */ PLAYER_ACTION_CHG_2, + /* 4 */ PLAYER_ACTION_CHG_3, + /* 5 */ PLAYER_ACTION_CHG_5, + /* 6 */ PLAYER_ACTION_CHG_4, + /* 7 */ PLAYER_ACTION_CHG_9, + /* 8 */ PLAYER_ACTION_CHG_8, + /* 9 */ PLAYER_ACTION_CHG_7, + /* 10 */ -PLAYER_ACTION_CHG_6, +}; + +s8 sPlayerActionChangeList8[] = { + /* 0 */ PLAYER_ACTION_CHG_0, + /* 1 */ PLAYER_ACTION_CHG_11, + /* 2 */ PLAYER_ACTION_CHG_1, + /* 3 */ PLAYER_ACTION_CHG_2, + /* 4 */ PLAYER_ACTION_CHG_3, + /* 5 */ PLAYER_ACTION_CHG_12, + /* 6 */ PLAYER_ACTION_CHG_5, + /* 7 */ PLAYER_ACTION_CHG_4, + /* 8 */ PLAYER_ACTION_CHG_9, + /* 9 */ PLAYER_ACTION_CHG_8, + /* 10 */ PLAYER_ACTION_CHG_7, + /* 11 */ -PLAYER_ACTION_CHG_6, +}; + +s8 sPlayerActionChangeList9[] = { + /* 0 */ PLAYER_ACTION_CHG_13, + /* 1 */ PLAYER_ACTION_CHG_1, + /* 2 */ PLAYER_ACTION_CHG_2, + /* 3 */ PLAYER_ACTION_CHG_3, + /* 4 */ PLAYER_ACTION_CHG_12, + /* 5 */ PLAYER_ACTION_CHG_5, + /* 6 */ PLAYER_ACTION_CHG_4, + /* 7 */ PLAYER_ACTION_CHG_9, + /* 8 */ PLAYER_ACTION_CHG_10, + /* 9 */ PLAYER_ACTION_CHG_11, + /* 10 */ PLAYER_ACTION_CHG_8, + /* 11 */ PLAYER_ACTION_CHG_7, + /* 12 */ -PLAYER_ACTION_CHG_6, +}; + +s8 sPlayerActionChangeList10[] = { + /* 0 */ PLAYER_ACTION_CHG_10, + /* 1 */ PLAYER_ACTION_CHG_8, + /* 2 */ -PLAYER_ACTION_CHG_7, +}; + +s8 sPlayerActionChangeList11[] = { + /* 0 */ PLAYER_ACTION_CHG_0, + /* 1 */ PLAYER_ACTION_CHG_12, + /* 2 */ PLAYER_ACTION_CHG_5, + /* 3 */ PLAYER_ACTION_CHG_4, + /* 4 */ -PLAYER_ACTION_CHG_14, +}; + +s8 sPlayerActionChangeList12[] = { + /* 0 */ PLAYER_ACTION_CHG_13, + /* 1 */ PLAYER_ACTION_CHG_2, + /* 2 */ -PLAYER_ACTION_CHG_4, +}; + +s32 (*sPlayerActionChangeFuncs[PLAYER_ACTION_CHG_MAX])(Player*, PlayState*) = { + Player_ActionChange_0, // PLAYER_ACTION_CHG_0 + Player_ActionChange_1, // PLAYER_ACTION_CHG_1 + Player_ActionChange_2, // PLAYER_ACTION_CHG_2 + Player_ActionChange_3, // PLAYER_ACTION_CHG_3 + Player_ActionChange_4, // PLAYER_ACTION_CHG_4 + Player_ActionChange_5, // PLAYER_ACTION_CHG_5 + Player_ActionChange_6, // PLAYER_ACTION_CHG_6 + Player_ActionChange_7, // PLAYER_ACTION_CHG_7 + Player_ActionChange_8, // PLAYER_ACTION_CHG_8 + Player_ActionChange_9, // PLAYER_ACTION_CHG_9 + Player_ActionChange_10, // PLAYER_ACTION_CHG_10 + Player_ActionChange_11, // PLAYER_ACTION_CHG_11 + Player_ActionChange_12, // PLAYER_ACTION_CHG_12 + Player_ActionChange_13, // PLAYER_ACTION_CHG_13 + Player_ActionChange_14, // PLAYER_ACTION_CHG_14 +}; + +/** + * This function processes "Action Change Lists", which run various functions that + * check if it is appropriate to change to a new action. + * + * Action Change Lists are a list of indices for the `sPlayerActionChangeFuncs` array. + * The functions are ran in order until one of them returns true, or the end of the list is reached. + * An Action Change index having a negative value indicates that it is the last member in the list. + * + * Because these lists are processed sequentially, the order of the indices in the list determines its priority. + * + * If the `updateUpperBody` argument is true, Player's upper body will update before the Action Change List + * is processed. This allows for Upper Action functions to run. + * + * @return true if a new action has been chosen + * + */ +s32 Player_TryActionChangeList(PlayState* play, Player* this, s8* actionChangeList, s32 updateUpperBody) { if (!(this->stateFlags1 & (PLAYER_STATE1_1 | PLAYER_STATE1_80 | PLAYER_STATE1_20000000)) && !func_8082DA90(play)) { - if (arg3) { + if (updateUpperBody) { D_80862B04 = func_8083216C(this, play); if (Player_Action_64 == this->actionFunc) { return true; @@ -4860,14 +5026,16 @@ s32 func_80833058(PlayState* play, Player* this, s8* arg2, s32 arg3) { } if (!(this->stateFlags3 & PLAYER_STATE3_40000000) && (Player_UpperAction_2 != this->upperActionFunc)) { - while (*arg2 >= 0) { - if (D_8085D054[*arg2](this, play)) { + // Process all entries in the Action Change List with a positive index + while (*actionChangeList >= 0) { + if (sPlayerActionChangeFuncs[*actionChangeList](this, play)) { return true; } - arg2++; + actionChangeList++; } - if (D_8085D054[-*arg2](this, play)) { + // Try the last entry in the list. Negate the index to make it positive again. + if (sPlayerActionChangeFuncs[-*actionChangeList](this, play)) { return true; } } @@ -4887,7 +5055,7 @@ s32 func_808331FC(PlayState* play, Player* this, SkelAnime* skelAnime, f32 frame f32 speedTarget; s16 yawTarget; - if (func_80833058(play, this, D_8085D01C, 1)) { + if (Player_TryActionChangeList(play, this, sPlayerActionChangeList7, true)) { return 0; } @@ -5637,7 +5805,7 @@ void func_80834DB8(Player* this, PlayerAnimationHeader* anim, f32 speed, PlaySta func_80834D50(play, this, anim, speed, NA_SE_VO_LI_SWORD_N); } -s32 func_80834DFC(Player* this, PlayState* play) { +s32 Player_ActionChange_12(Player* this, PlayState* play) { if ((this->transformation != PLAYER_FORM_GORON) && ((this->transformation != PLAYER_FORM_DEKU) || func_801242B4(this) || (this->ledgeClimbType <= PLAYER_LEDGE_CLIMB_3)) && @@ -6229,7 +6397,7 @@ void Player_Door_Knob(PlayState* play, Player* this, Actor* door) { } // door stuff -s32 func_808365DC(Player* this, PlayState* play) { +s32 Player_ActionChange_1(Player* this, PlayState* play) { if ((gSaveContext.save.saveInfo.playerData.health != 0) && (this->doorType != PLAYER_DOORTYPE_NONE)) { if ((this->actor.category != ACTORCAT_PLAYER) || ((((this->doorType <= PLAYER_DOORTYPE_TALKING) && CutsceneManager_IsNext(CS_ID_GLOBAL_TALK)) || @@ -7205,7 +7373,7 @@ PlayerAnimationHeader* D_8085D1F8[] = { &gPlayerAnim_link_normal_take_out, // Hold up cutscene item; "this item doesn't work here" }; -s32 func_80838A90(Player* this, PlayState* play) { +s32 Player_ActionChange_13(Player* this, PlayState* play) { PlayerBottle bottleAction; if (this->unk_AA5 != PLAYER_UNKAA5_0) { @@ -7382,7 +7550,7 @@ s32 func_80838A90(Player* this, PlayState* play) { return false; } -s32 func_808391D8(Player* this, PlayState* play) { +s32 Player_ActionChange_4(Player* this, PlayState* play) { if (gSaveContext.save.saveInfo.playerData.health != 0) { Actor* talkActor = this->talkActor; Actor* lockOnActor = this->lockOnActor; @@ -7468,9 +7636,9 @@ s32 func_808391D8(Player* this, PlayState* play) { return false; } -s32 func_80839518(Player* this, PlayState* play) { +s32 Player_ActionChange_0(Player* this, PlayState* play) { if (this->unk_AA5 != PLAYER_UNKAA5_0) { - func_80838A90(this, play); + Player_ActionChange_13(this, play); return true; } else if ((this->lockOnActor != NULL) && (CHECK_FLAG_ALL(this->lockOnActor->flags, ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_40000) || @@ -7599,7 +7767,7 @@ s32 func_80839A84(PlayState* play, Player* this) { return true; } -s32 func_80839B18(Player* this, PlayState* play) { +s32 Player_ActionChange_10(Player* this, PlayState* play) { if (CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_A) && (play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) && (sPlayerFloorType != FLOOR_TYPE_7) && (sPlayerFloorEffect != FLOOR_EFFECT_1)) { @@ -7719,14 +7887,14 @@ void func_8083A04C(Player* this) { } } -s32 func_8083A0CC(Player* this, PlayState* play) { +s32 Player_ActionChange_14(Player* this, PlayState* play) { if (!D_80862B04 && (this->transformation == PLAYER_FORM_ZORA)) { func_8083A04C(this); } return false; } -s32 func_8083A114(Player* this, PlayState* play) { +s32 Player_ActionChange_6(Player* this, PlayState* play) { if (!D_80862B04 && !(this->stateFlags1 & PLAYER_STATE1_800000) && !func_8082FB68(this)) { if ((this->transformation == PLAYER_FORM_ZORA) && (this->stateFlags1 & PLAYER_STATE1_8000000)) { func_8083A04C(this); @@ -7751,7 +7919,7 @@ s32 func_8083A114(Player* this, PlayState* play) { return false; } -s32 func_8083A274(Player* this, PlayState* play) { +s32 Player_ActionChange_11(Player* this, PlayState* play) { if (CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_R) && (this->unk_AA5 == PLAYER_UNKAA5_0) && (play->unk_1887C == 0)) { if (Player_IsGoronOrDeku(this) || @@ -7821,7 +7989,7 @@ void func_8083A548(Player* this) { } } -s32 func_8083A580(Player* this, PlayState* play) { +s32 Player_ActionChange_8(Player* this, PlayState* play) { if (CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_B)) { if (!(this->stateFlags1 & PLAYER_STATE1_400000) && (Player_GetMeleeWeaponHeld(this) != PLAYER_MELEEWEAPON_NONE)) { @@ -8656,7 +8824,7 @@ u16 D_8085D25C[] = { }; // Player_MountHorse -s32 func_8083CCB4(Player* this, PlayState* play) { +s32 Player_ActionChange_3(Player* this, PlayState* play) { EnHorse* rideActor = (EnHorse*)this->rideActor; if (rideActor != NULL) { @@ -8797,7 +8965,7 @@ void func_8083D168(PlayState* play, Player* this, GetItemEntry* giEntry) { Audio_PlaySfx((this->getItemId < GI_NONE) ? NA_SE_SY_GET_BOXITEM : NA_SE_SY_GET_ITEM); } -s32 func_8083D23C(Player* this, PlayState* play) { +s32 Player_ActionChange_2(Player* this, PlayState* play) { if (gSaveContext.save.saveInfo.playerData.health != 0) { Actor* interactRangeActor = this->interactRangeActor; @@ -8923,7 +9091,7 @@ s32 func_8083D738(Player* this, Actor* heldActor) { return true; } -s32 func_8083D78C(Player* this, PlayState* play) { +s32 Player_ActionChange_9(Player* this, PlayState* play) { if (this->stateFlags1 & PLAYER_STATE1_800) { if ((this->heldActor != NULL) && CHECK_BTN_ANY(sPlayerControlInput->press.button, BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_B | BTN_A)) { @@ -9120,7 +9288,7 @@ void func_8083DF38(Player* this, PlayerAnimationHeader* anim, PlayState* play) { this->actor.shape.rot.y = this->currentYaw = this->actor.wallYaw + 0x8000; } -s32 func_8083DFC4(Player* this, PlayState* play) { +s32 Player_ActionChange_5(Player* this, PlayState* play) { if (!(this->stateFlags1 & PLAYER_STATE1_800) && (this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && (sPlayerShapeYawToTouchedWall < 0x3000)) { if ((this->linearVelocity > 0.0f) && func_8083D860(this, play)) { @@ -9290,7 +9458,7 @@ s32 func_8083E7F8(Player* this, f32* arg1, s16* arg2, PlayState* play) { func_8083C6E8(this, play); if ((*arg1 != 0.0f) || (ABS_ALT(this->unk_B4C) > 0x190)) { - s16 temp_a0 = *arg2 - (u16)Camera_GetInputDirYaw(play->cameraPtrs[play->activeCamId]); + s16 temp_a0 = *arg2 - (u16)Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)); u16 temp; temp = (ABS_ALT(temp_a0) - 0x2000); @@ -9730,7 +9898,7 @@ s32 func_8083FD80(Player* this, PlayState* play) { } s32 func_8083FE38(Player* this, PlayState* play) { - return func_80838A90(this, play) || func_808391D8(this, play) || func_8083D23C(this, play); + return Player_ActionChange_13(this, play) || Player_ActionChange_4(this, play) || Player_ActionChange_2(this, play); } void Player_RequestQuakeAndRumble(PlayState* play, Player* this, u16 sfxId) { @@ -12662,7 +12830,7 @@ s32 func_80847994(PlayState* play, Player* this) { this->stateFlags3 &= ~PLAYER_STATE3_20; this->itemAction = PLAYER_IA_OCARINA; this->unk_AA5 = PLAYER_UNKAA5_5; - func_80838A90(this, play); + Player_ActionChange_13(this, play); return true; } return false; @@ -12966,7 +13134,7 @@ void func_808484F0(Player* this) { } } -s32 func_80848570(Player* this, PlayState* play) { +s32 Player_ActionChange_7(Player* this, PlayState* play) { if (!func_8083A6C0(play, this)) { if (func_808396B8(play, this)) { PlayerMeleeWeaponAnimation meleeWeaponAnim = func_808335F4(this); @@ -13498,7 +13666,7 @@ void Player_Action_2(Player* this, PlayState* play) { } func_80832F24(this); - if (func_80833058(play, this, D_8085CFE4, 1)) { + if (Player_TryActionChangeList(play, this, sPlayerActionChangeList1, true)) { return; } @@ -13553,7 +13721,7 @@ void Player_Action_3(Player* this, PlayState* play) { } func_80832F24(this); - if (func_80833058(play, this, D_8085CFEC, 1)) { + if (Player_TryActionChangeList(play, this, sPlayerActionChangeList2, true)) { return; } @@ -13622,7 +13790,8 @@ void Player_Action_4(Player* this, PlayState* play) { } func_80832F24(this); - if ((this->actionVar2 == 0) && !func_80847880(play, this) && !func_80833058(play, this, D_8085D01C, 1)) { + if ((this->actionVar2 == 0) && !func_80847880(play, this) && + !Player_TryActionChangeList(play, this, sPlayerActionChangeList7, true)) { if (func_8082FB68(this)) { func_8083B23C(this, play); return; @@ -13689,7 +13858,7 @@ void Player_Action_5(Player* this, PlayState* play) { Player_AnimSfx_PlayFloorWalk(this, this->linearVelocity); } - if (func_80833058(play, this, D_8085CFF8, 1)) { + if (Player_TryActionChangeList(play, this, sPlayerActionChangeList3, true)) { return; } @@ -13741,7 +13910,7 @@ void Player_Action_6(Player* this, PlayState* play) { s32 sp2C; func_8083EE60(this, play); - if (func_80833058(play, this, D_8085D004, 1)) { + if (Player_TryActionChangeList(play, this, sPlayerActionChangeList4, true)) { return; } @@ -13781,7 +13950,7 @@ void Player_Action_7(Player* this, PlayState* play) { func_80832F24(this); - if (func_80833058(play, this, D_8085D004, 1)) { + if (Player_TryActionChangeList(play, this, sPlayerActionChangeList4, true)) { return; } @@ -13802,7 +13971,7 @@ void Player_Action_7(Player* this, PlayState* play) { void Player_Action_8(Player* this, PlayState* play) { s32 animFinished = PlayerAnimation_Update(play, &this->skelAnime); - if (func_80833058(play, this, D_8085D004, 1)) { + if (Player_TryActionChangeList(play, this, sPlayerActionChangeList4, true)) { return; } @@ -13817,7 +13986,7 @@ void Player_Action_9(Player* this, PlayState* play) { s32 var_v0; func_8083F27C(play, this); - if (func_80833058(play, this, D_8085D00C, 1)) { + if (Player_TryActionChangeList(play, this, sPlayerActionChangeList5, true)) { return; } @@ -13887,7 +14056,7 @@ void Player_Action_10(Player* this, PlayState* play) { yawTarget = this->actor.home.rot.y; } - if (func_80833058(play, this, D_8085D018, 1)) { + if (Player_TryActionChangeList(play, this, sPlayerActionChangeList6, true)) { return; } @@ -13910,8 +14079,8 @@ void Player_Action_11(Player* this, PlayState* play) { } PlayerAnimation_Update(play, &this->skelAnime); - if (!func_80847880(play, this) && - (!func_80833058(play, this, D_8085D01C, 1) || (Player_Action_11 == this->actionFunc))) { + if (!func_80847880(play, this) && (!Player_TryActionChangeList(play, this, sPlayerActionChangeList7, true) || + (Player_Action_11 == this->actionFunc))) { f32 speedTarget; f32 temp_fv0; f32 temp_fv1; @@ -13951,7 +14120,8 @@ void Player_Action_12(Player* this, PlayState* play) { PlayerAnimation_Update(play, &this->skelAnime); func_80832F24(this); if (!func_80847880(play, this)) { - if (!func_80833058(play, this, D_8085D01C, 0) || (Player_Action_12 == this->actionFunc)) { + if (!Player_TryActionChangeList(play, this, sPlayerActionChangeList7, false) || + (Player_Action_12 == this->actionFunc)) { if (!CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_B)) { func_80839E74(this, play); } @@ -13965,7 +14135,7 @@ void Player_Action_13(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_20; func_8083F57C(this, play); - if (func_80833058(play, this, D_8085D028, 1)) { + if (Player_TryActionChangeList(play, this, sPlayerActionChangeList8, true)) { return; } @@ -13996,7 +14166,7 @@ void Player_Action_14(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_20; func_8083F57C(this, play); - if (func_80833058(play, this, D_8085D034, 1)) { + if (Player_TryActionChangeList(play, this, sPlayerActionChangeList9, true)) { return; } @@ -14026,7 +14196,7 @@ void Player_Action_15(Player* this, PlayState* play) { f32 speedTarget; s16 yawTarget; - if (func_80833058(play, this, D_8085D00C, 1)) { + if (Player_TryActionChangeList(play, this, sPlayerActionChangeList5, true)) { return; } @@ -14053,7 +14223,7 @@ void Player_Action_16(Player* this, PlayState* play) { s16 yawTarget; func_80832F24(this); - if (func_80833058(play, this, D_8085D044, 1)) { + if (Player_TryActionChangeList(play, this, sPlayerActionChangeList10, true)) { return; } @@ -14080,7 +14250,7 @@ void Player_Action_17(Player* this, PlayState* play) { } if (DECR(this->actionVar2) == 0) { - if (!func_80838A90(this, play)) { + if (!Player_ActionChange_13(this, play)) { func_80836A98(this, D_8085BE84[PLAYER_ANIMGROUP_33][this->modelAnimType], play); } this->actor.flags &= ~ACTOR_FLAG_TALK_REQUESTED; @@ -14096,7 +14266,7 @@ void Player_Action_18(Player* this, PlayState* play) { SkelAnime_Update(&this->unk_2C8); if (!func_8083FE38(this, play)) { - if (!func_8083A274(this, play)) { + if (!Player_ActionChange_11(this, play)) { this->stateFlags1 &= ~PLAYER_STATE1_400000; if (this->itemAction <= PLAYER_IA_MINUS1) { @@ -14134,7 +14304,7 @@ void Player_Action_18(Player* this, PlayState* play) { if (this->actionVar2 != 0) { f32 yStick = sPlayerControlInput->rel.stick_y * 180; f32 xStick = sPlayerControlInput->rel.stick_x * -120; - s16 temp_a0 = this->actor.shape.rot.y - Camera_GetInputDirYaw(play->cameraPtrs[play->activeCamId]); + s16 temp_a0 = this->actor.shape.rot.y - Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)); s16 var_a1; s16 temp_ft5; s16 var_a2; @@ -14164,7 +14334,7 @@ void Player_Action_18(Player* this, PlayState* play) { this->actionVar1 = 0; } } else if (!func_8083FE38(this, play)) { - if (func_8083A274(this, play)) { + if (Player_ActionChange_11(this, play)) { func_8083FD80(this, play); } else { this->stateFlags1 &= ~PLAYER_STATE1_400000; @@ -14464,7 +14634,7 @@ void Player_Action_25(Player* this, PlayState* play) { func_8083216C(this, play); } - func_80838A90(this, play); + Player_ActionChange_13(this, play); } // sPlayerRollingAnimSfx @@ -14510,7 +14680,7 @@ void Player_Action_26(Player* this, PlayState* play) { } } } else if (!func_80840A30(play, this, &this->linearVelocity, 6.0f)) { - if ((this->skelAnime.curFrame < 15.0f) || !func_80848570(this, play)) { + if ((this->skelAnime.curFrame < 15.0f) || !Player_ActionChange_7(this, play)) { f32 speedTarget; s16 yawTarget; @@ -14851,7 +15021,7 @@ void Player_Action_34(Player* this, PlayState* play) { } void Player_Action_35(Player* this, PlayState* play) { - if (func_80838A90(this, play) == 0) { + if (!Player_ActionChange_13(this, play)) { if ((this->stateFlags3 & PLAYER_STATE3_10) && !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { func_80833AA0(this, play); this->stateFlags1 |= PLAYER_STATE1_20000000; @@ -15005,7 +15175,7 @@ void Player_Action_35(Player* this, PlayState* play) { if (play->sceneId == SCENE_20SICHITAI) { play->unk_1887C = 0; } - } else if (!func_808391D8(this, play)) { + } else if (!Player_ActionChange_4(this, play)) { func_8083B2E4(this, play); } } @@ -15206,7 +15376,7 @@ void Player_Action_43(Player* this, PlayState* play) { ((this->unk_AA5 == PLAYER_UNKAA5_1) && CHECK_BTN_ANY(sPlayerControlInput->press.button, BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_CUP | BTN_R | BTN_B | BTN_A))) || - func_808391D8(this, play)))) { + Player_ActionChange_4(this, play)))) { func_80839ED0(this, play); Audio_PlaySfx(NA_SE_SY_CAMERA_ZOOM_UP); } else if ((DECR(this->actionVar2) == 0) || (this->unk_AA5 != PLAYER_UNKAA5_3)) { @@ -15239,7 +15409,7 @@ void Player_Action_44(Player* this, PlayState* play) { func_80837BD0(play, this); this->actionVar2 = sp44; } else if (!func_80847994(play, this) && !func_80847880(play, this) && !func_808387A0(play, this) && - ((this->talkActor != this->interactRangeActor) || !func_8083D23C(this, play))) { + ((this->talkActor != this->interactRangeActor) || !Player_ActionChange_2(this, play))) { if (func_801242B4(this)) { func_808353DC(play, this); } else { @@ -15893,8 +16063,8 @@ void Player_Action_52(Player* this, PlayState* play) { func_8084FD7C(play, this, &rideActor->actor); } } else if ((this->csMode != PLAYER_CSMODE_NONE) || - (!func_8082DAFC(play) && ((rideActor->actor.speed != 0.0f) || !func_808391D8(this, play)) && - !func_80847BF0(this, play) && !func_80838A90(this, play))) { + (!func_8082DAFC(play) && ((rideActor->actor.speed != 0.0f) || !Player_ActionChange_4(this, play)) && + !func_80847BF0(this, play) && !Player_ActionChange_13(this, play))) { if (this->lockOnActor != NULL) { if (func_800B7128(this)) { this->upperLimbRot.y = func_8083C62C(this, true) - this->actor.shape.rot.y; @@ -16007,7 +16177,7 @@ void Player_Action_54(Player* this, PlayState* play) { this->actionVar2 = 0; } - if (!func_8082DAFC(play) && !func_80833058(play, this, D_8085D048, 1) && + if (!func_8082DAFC(play) && !Player_TryActionChangeList(play, this, sPlayerActionChangeList11, true) && !func_8083B3B4(play, this, sPlayerControlInput) && ((this->actionVar2 != 0) || !func_80850734(play, this))) { speedTarget = 0.0f; yawTarget = this->actor.shape.rot.y; @@ -16044,7 +16214,7 @@ void Player_Action_54(Player* this, PlayState* play) { } void Player_Action_55(Player* this, PlayState* play) { - if (!func_80838A90(this, play)) { + if (!Player_ActionChange_13(this, play)) { this->stateFlags2 |= PLAYER_STATE2_20; func_808477D0(play, this, NULL, this->linearVelocity); func_808475B4(this); @@ -16090,7 +16260,7 @@ void Player_Action_56(Player* this, PlayState* play) { func_808475B4(this); func_8082F164(this, BTN_R); - if (func_80833058(play, this, D_8085D048, false)) { + if (Player_TryActionChangeList(play, this, sPlayerActionChangeList11, false)) { return; } @@ -16217,8 +16387,8 @@ void Player_Action_57(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_20; func_808475B4(this); func_8082F164(this, BTN_R); - if (!func_80833058(play, this, D_8085D048, 1) && !func_8083B3B4(play, this, sPlayerControlInput) && - !func_80850854(play, this)) { + if (!Player_TryActionChangeList(play, this, sPlayerActionChangeList11, true) && + !func_8083B3B4(play, this, sPlayerControlInput) && !func_80850854(play, this)) { func_808477D0(play, this, sPlayerControlInput, this->linearVelocity); if (func_8082DA90(play)) { speedTarget = this->linearVelocity; @@ -16249,7 +16419,8 @@ void Player_Action_58(Player* this, PlayState* play) { func_808475B4(this); func_8082F164(this, BTN_R); - if (!func_80833058(play, this, D_8085D048, 1) && !func_8083B3B4(play, this, sPlayerControlInput)) { + if (!Player_TryActionChangeList(play, this, sPlayerActionChangeList11, true) && + !func_8083B3B4(play, this, sPlayerControlInput)) { Player_GetMovementSpeedAndYaw(this, &speedTarget, &yawTarget, SPEED_MODE_LINEAR, play); if (speedTarget == 0.0f) { @@ -16271,7 +16442,7 @@ void Player_Action_59(Player* this, PlayState* play) { func_8083216C(this, play); func_8082F164(this, BTN_R); - if (func_80838A90(this, play)) { + if (Player_ActionChange_13(this, play)) { return; } @@ -16292,7 +16463,7 @@ void Player_Action_59(Player* this, PlayState* play) { func_808477D0(play, this, sPlayerControlInput, this->actor.velocity.y); this->unk_AAA = 0x3E80; - if (CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_A) && !func_8083D23C(this, play) && + if (CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_A) && !Player_ActionChange_2(this, play) && !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->actor.depthInWater < 120.0f)) { func_808481CC(play, this, -2.0f); } else { @@ -16596,7 +16767,7 @@ void Player_Action_63(Player* this, PlayState* play) { this->talkActor = this->tatlActor; this->tatlActor->textId = -this->tatlTextId; Player_TalkWithPlayer(play, this->talkActor); - } else if (!func_80838A90(this, play)) { + } else if (!Player_ActionChange_13(this, play)) { func_80836A5C(this, play); Player_AnimationPlayOnceReverse(play, this, D_8085D17C[this->transformation]); } @@ -16775,8 +16946,8 @@ void Player_Action_65(Player* this, PlayState* play) { } else { if ((this->skelAnime.animation == &gPlayerAnim_link_demo_get_itemB) || (this->skelAnime.animation == &gPlayerAnim_pn_getB)) { - Math_ScaledStepToS(&this->actor.shape.rot.y, - BINANG_ADD(Camera_GetCamDirYaw(play->cameraPtrs[play->activeCamId]), 0x8000), 0xFA0); + Math_ScaledStepToS(&this->actor.shape.rot.y, BINANG_ADD(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)), 0x8000), + 0xFA0); } else if ((this->skelAnime.animation == &gPlayerAnim_pn_getA) && PlayerAnimation_OnFrame(&this->skelAnime, 10.0f)) { Player_AnimSfx_PlayFloorLand(this); @@ -17090,7 +17261,7 @@ void Player_Action_70(Player* this, PlayState* play) { if (PlayerAnimation_Update(play, &this->skelAnime)) { Player_StopCutscene(this); - if (!func_80838A90(this, play)) { + if (!Player_ActionChange_13(this, play)) { func_80839E74(this, play); } } else if (PlayerAnimation_OnFrame(&this->skelAnime, 76.0f)) { @@ -17198,11 +17369,11 @@ void Player_Action_73(Player* this, PlayState* play) { Audio_PlaySfx_AtPosWithSyncedFreqAndVolume( &this->actor.projectedPos, Player_GetFloorSfx(this, NA_SE_PL_SLIP_LEVEL - SFX_FLAG), this->actor.speed); - if (func_80838A90(this, play)) { + if (Player_ActionChange_13(this, play)) { return; } - if ((this->transformation == PLAYER_FORM_GORON) && func_8083A114(this, play)) { + if ((this->transformation == PLAYER_FORM_GORON) && Player_ActionChange_6(this, play)) { return; } @@ -17326,7 +17497,7 @@ void Player_Action_77(Player* this, PlayState* play) { } void Player_Action_78(Player* this, PlayState* play) { - func_808365DC(this, play); + Player_ActionChange_1(this, play); } void Player_Action_79(Player* this, PlayState* play) { @@ -17482,7 +17653,7 @@ void Player_Action_84(Player* this, PlayState* play) { func_808333CC(this))) { D_80862B48 = this->actionVar2; - if (!func_80848570(this, play)) { + if (!Player_ActionChange_7(this, play)) { PlayerAnimationHeader* anim = func_80123420(this) ? attackInfoEntry->unk_8 : attackInfoEntry->unk_4; func_8082DC38(this); @@ -17494,7 +17665,7 @@ void Player_Action_84(Player* this, PlayState* play) { u8 moveFlags = this->skelAnime.moveFlags; if (this->transformation == PLAYER_FORM_ZORA) { - if (func_8083A580(this, play)) { + if (Player_ActionChange_8(this, play)) { anim = this->unk_284.animation; } this->unk_ADC = 0; @@ -17737,10 +17908,10 @@ void Player_Action_86(Player* this, PlayState* play) { func_808323C0(this, play->playerCsIds[PLAYER_CS_ID_MASK_TRANSFORMATION]); sPlayerControlInput = play->state.input; - Camera_ChangeMode(play->cameraPtrs[play->activeCamId], + Camera_ChangeMode(GET_ACTIVE_CAM(play), (this->transformation == PLAYER_FORM_HUMAN) ? CAM_MODE_NORMAL : CAM_MODE_JUMP); this->stateFlags2 |= PLAYER_STATE2_40; - this->actor.shape.rot.y = Camera_GetCamDirYaw(play->cameraPtrs[play->activeCamId]) + 0x8000; + this->actor.shape.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000; func_80855218(play, this, &sp4C); @@ -17814,8 +17985,7 @@ void Player_Action_86(Player* this, PlayState* play) { } void Player_Action_87(Player* this, PlayState* play) { - Camera_ChangeMode(play->cameraPtrs[play->activeCamId], - (this->prevMask == PLAYER_MASK_NONE) ? CAM_MODE_NORMAL : CAM_MODE_JUMP); + Camera_ChangeMode(GET_ACTIVE_CAM(play), (this->prevMask == PLAYER_MASK_NONE) ? CAM_MODE_NORMAL : CAM_MODE_JUMP); if (R_PLAY_FILL_SCREEN_ON != 0) { R_PLAY_FILL_SCREEN_ALPHA -= R_PLAY_FILL_SCREEN_ON; @@ -18027,7 +18197,7 @@ void Player_Action_93(Player* this, PlayState* play) { PlayerAnimation_Update(play, &this->skelAnime); - if (func_80838A90(this, play)) { + if (Player_ActionChange_13(this, play)) { return; } @@ -18048,7 +18218,7 @@ void Player_Action_93(Player* this, PlayState* play) { if (this->unk_ABC < -3900.0f) { this->unk_ABC = -3900.0f; this->actionVar1 = 2; - this->actor.shape.rot.y = Camera_GetInputDirYaw(play->cameraPtrs[play->activeCamId]); + this->actor.shape.rot.y = Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)); this->actor.scale.y = 0.01f; this->currentYaw = this->actor.world.rot.y = this->actor.shape.rot.y; } else { @@ -18211,7 +18381,7 @@ void Player_Action_94(Player* this, PlayState* play) { this->boomerangActor = NULL; } - if (func_80838A90(this, play)) { + if (Player_ActionChange_13(this, play)) { return; } @@ -18404,7 +18574,7 @@ void Player_Action_95(Player* this, PlayState* play) { PlayerAnimation_Update(play, &this->skelAnime); Player_SetCylinderForAttack(this, DMG_DEKU_SPIN, 1, 30); - if (!func_80838A90(this, play)) { + if (!Player_ActionChange_13(this, play)) { s16 prevYaw = this->currentYaw; f32 speedTarget; s16 yawTarget; @@ -18554,7 +18724,7 @@ void func_80857AEC(PlayState* play, Player* this) { // Goron rolling related void Player_Action_96(Player* this, PlayState* play) { - if (func_80833058(play, this, D_8085D050, 0)) { + if (Player_TryActionChangeList(play, this, sPlayerActionChangeList12, false)) { return; } @@ -19502,7 +19672,7 @@ void Player_CsAction_0(PlayState* play, Player* this, CsCmdActorCue* cue) { if (func_801240DC(this) || (this->stateFlags1 & PLAYER_STATE1_800)) { func_8083216C(this, play); } else if ((this->interactRangeActor != NULL) && (this->interactRangeActor->textId == 0xFFFF)) { - func_8083D23C(this, play); + Player_ActionChange_2(this, play); } } } @@ -19920,7 +20090,7 @@ void Player_CsAction_38(PlayState* play, Player* this, CsCmdActorCue* cue) { void Player_CsAction_39(PlayState* play, Player* this, CsCmdActorCue* cue) { Player_CsAnim_11(play, this, cue); - if (func_8083D23C(this, play)) { + if (Player_ActionChange_2(this, play)) { play->csCtx.state = CS_STATE_STOP; CutsceneManager_Stop(CutsceneManager_GetCurrentCsId()); } @@ -20010,8 +20180,8 @@ void Player_CsAction_End(PlayState* play, Player* this, CsCmdActorCue* cue) { func_8082DC64(play, this); } else { func_80839ED0(this, play); - if (!func_808391D8(this, play)) { - func_8083D23C(this, play); + if (!Player_ActionChange_4(this, play)) { + Player_ActionChange_2(this, play); } } @@ -20079,7 +20249,7 @@ void Player_CsAction_48(PlayState* play, Player* this, CsCmdActorCue* cue) { if ((sPlayerCsModes[this->cueId] == PLAYER_CSMODE_68) && (play->sceneId == SCENE_OKUJOU)) { this->unk_AA5 = PLAYER_UNKAA5_5; - if (func_80838A90(this, play)) { + if (Player_ActionChange_13(this, play)) { this->csMode = PLAYER_CSMODE_NONE; } return; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index d7350076d..7ecc8c4e3 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -4383,7 +4383,7 @@ 0x80832CAC:("Player_CalcSpeedAndYawFromControlStick",), 0x80832F24:("func_80832F24",), 0x80832F78:("Player_GetMovementSpeedAndYaw",), - 0x80833058:("func_80833058",), + 0x80833058:("Player_TryActionChangeList",), 0x808331FC:("func_808331FC",), 0x808332A0:("func_808332A0",), 0x808333CC:("func_808333CC",), @@ -4413,7 +4413,7 @@ 0x80834CD0:("func_80834CD0",), 0x80834D50:("func_80834D50",), 0x80834DB8:("func_80834DB8",), - 0x80834DFC:("func_80834DFC",), + 0x80834DFC:("Player_ActionChange_12",), 0x80835324:("func_80835324",), 0x808353DC:("func_808353DC",), 0x80835428:("func_80835428",), @@ -4430,7 +4430,7 @@ 0x80835EAC:("Player_Door_Staircase",), 0x8083604C:("Player_Door_Sliding",), 0x80836258:("Player_Door_Knob",), - 0x808365DC:("func_808365DC",), + 0x808365DC:("Player_ActionChange_1",), 0x80836888:("func_80836888",), 0x8083692C:("func_8083692C",), 0x80836988:("func_80836988",), @@ -4470,9 +4470,9 @@ 0x808388B8:("func_808388B8",), 0x808389BC:("func_808389BC",), 0x80838A20:("func_80838A20",), - 0x80838A90:("func_80838A90",), - 0x808391D8:("func_808391D8",), - 0x80839518:("func_80839518",), + 0x80838A90:("Player_ActionChange_13",), + 0x808391D8:("Player_ActionChange_4",), + 0x80839518:("Player_ActionChange_0",), 0x808395F0:("func_808395F0",), 0x808396B8:("func_808396B8",), 0x80839770:("func_80839770",), @@ -4481,19 +4481,19 @@ 0x80839978:("func_80839978",), 0x80839A10:("func_80839A10",), 0x80839A84:("func_80839A84",), - 0x80839B18:("func_80839B18",), + 0x80839B18:("Player_ActionChange_10",), 0x80839CD8:("func_80839CD8",), 0x80839E3C:("func_80839E3C",), 0x80839E74:("func_80839E74",), 0x80839ED0:("func_80839ED0",), 0x80839F98:("func_80839F98",), 0x8083A04C:("func_8083A04C",), - 0x8083A0CC:("func_8083A0CC",), - 0x8083A114:("func_8083A114",), - 0x8083A274:("func_8083A274",), + 0x8083A0CC:("Player_ActionChange_14",), + 0x8083A114:("Player_ActionChange_6",), + 0x8083A274:("Player_ActionChange_11",), 0x8083A4A4:("func_8083A4A4",), 0x8083A548:("func_8083A548",), - 0x8083A580:("func_8083A580",), + 0x8083A580:("Player_ActionChange_8",), 0x8083A658:("func_8083A658",), 0x8083A6C0:("func_8083A6C0",), 0x8083A794:("func_8083A794",), @@ -4531,19 +4531,19 @@ 0x8083CB04:("func_8083CB04",), 0x8083CB58:("func_8083CB58",), 0x8083CBC4:("func_8083CBC4",), - 0x8083CCB4:("func_8083CCB4",), + 0x8083CCB4:("Player_ActionChange_3",), 0x8083CF68:("Player_HandleSlopes",), 0x8083D168:("func_8083D168",), - 0x8083D23C:("func_8083D23C",), + 0x8083D23C:("Player_ActionChange_2",), 0x8083D6DC:("func_8083D6DC",), 0x8083D738:("func_8083D738",), - 0x8083D78C:("func_8083D78C",), + 0x8083D78C:("Player_ActionChange_9",), 0x8083D860:("func_8083D860",), 0x8083DCC4:("func_8083DCC4",), 0x8083DD1C:("func_8083DD1C",), 0x8083DEE4:("func_8083DEE4",), 0x8083DF38:("func_8083DF38",), - 0x8083DFC4:("func_8083DFC4",), + 0x8083DFC4:("Player_ActionChange_5",), 0x8083E14C:("func_8083E14C",), 0x8083E234:("func_8083E234",), 0x8083E28C:("func_8083E28C",), @@ -4642,7 +4642,7 @@ 0x808482E0:("func_808482E0",), 0x808484CC:("func_808484CC",), 0x808484F0:("func_808484F0",), - 0x80848570:("func_80848570",), + 0x80848570:("Player_ActionChange_7",), 0x80848640:("func_80848640",), 0x80848780:("Player_UpperAction_0",), 0x808487B8:("Player_UpperAction_1",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index f5905b769..01a46d7d1 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4967,19 +4967,19 @@ 0x8085CFCC:("D_8085CFCC","UNK_TYPE1","",0x1), 0x8085CFD4:("D_8085CFD4","UNK_TYPE1","",0x1), 0x8085CFDC:("D_8085CFDC","UNK_TYPE1","",0x1), - 0x8085CFE4:("D_8085CFE4","UNK_TYPE1","",0x1), - 0x8085CFEC:("D_8085CFEC","UNK_TYPE1","",0x1), - 0x8085CFF8:("D_8085CFF8","UNK_TYPE1","",0x1), - 0x8085D004:("D_8085D004","UNK_TYPE1","",0x1), - 0x8085D00C:("D_8085D00C","UNK_TYPE1","",0x1), - 0x8085D018:("D_8085D018","UNK_TYPE1","",0x1), - 0x8085D01C:("D_8085D01C","UNK_TYPE1","",0x1), - 0x8085D028:("D_8085D028","UNK_TYPE1","",0x1), - 0x8085D034:("D_8085D034","UNK_TYPE1","",0x1), - 0x8085D044:("D_8085D044","UNK_TYPE1","",0x1), - 0x8085D048:("D_8085D048","UNK_TYPE1","",0x1), - 0x8085D050:("D_8085D050","UNK_TYPE1","",0x1), - 0x8085D054:("D_8085D054","UNK_PTR","",0x4), + 0x8085CFE4:("sPlayerActionChangeList1","UNK_TYPE1","",0x1), + 0x8085CFEC:("sPlayerActionChangeList2","UNK_TYPE1","",0x1), + 0x8085CFF8:("sPlayerActionChangeList3","UNK_TYPE1","",0x1), + 0x8085D004:("sPlayerActionChangeList4","UNK_TYPE1","",0x1), + 0x8085D00C:("sPlayerActionChangeList5","UNK_TYPE1","",0x1), + 0x8085D018:("sPlayerActionChangeList6","UNK_TYPE1","",0x1), + 0x8085D01C:("sPlayerActionChangeList7","UNK_TYPE1","",0x1), + 0x8085D028:("sPlayerActionChangeList8","UNK_TYPE1","",0x1), + 0x8085D034:("sPlayerActionChangeList9","UNK_TYPE1","",0x1), + 0x8085D044:("sPlayerActionChangeList10","UNK_TYPE1","",0x1), + 0x8085D048:("sPlayerActionChangeList11","UNK_TYPE1","",0x1), + 0x8085D050:("sPlayerActionChangeList12","UNK_TYPE1","",0x1), + 0x8085D054:("sPlayerActionChangeFuncs","UNK_PTR","",0x4), 0x8085D090:("D_8085D090","UNK_TYPE1","",0x1), 0x8085D094:("D_8085D094","UNK_TYPE1","",0x6), 0x8085D09C:("D_8085D09C","UNK_TYPE4","",0x4), From 64b1fafd33bd7092c9cd2e703c3ccc41751c01a4 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Fri, 29 Sep 2023 13:39:25 +1000 Subject: [PATCH 5/9] Animation Cleanup: En_H* (#1399) * begin H * more cleanup --- src/overlays/actors/ovl_Boss_04/z_boss_04.c | 2 +- src/overlays/actors/ovl_Boss_04/z_boss_04.h | 2 +- .../actors/ovl_En_Bombers/z_en_bombers.c | 2 +- .../actors/ovl_En_Bombers/z_en_bombers.h | 2 +- src/overlays/actors/ovl_En_Egol/z_en_egol.c | 2 +- .../actors/ovl_En_Hanabi/z_en_hanabi.c | 1 + .../actors/ovl_En_Heishi/z_en_heishi.c | 45 +++--- .../actors/ovl_En_Heishi/z_en_heishi.h | 2 +- src/overlays/actors/ovl_En_Hg/z_en_hg.c | 55 ++++--- src/overlays/actors/ovl_En_Hgo/z_en_hgo.c | 68 +++++---- .../ovl_En_Hidden_Nuts/z_en_hidden_nuts.c | 107 ++++++++----- .../ovl_En_Hidden_Nuts/z_en_hidden_nuts.h | 9 +- .../actors/ovl_En_Hint_Skb/z_en_hint_skb.c | 113 ++++++++------ .../actors/ovl_En_Hint_Skb/z_en_hint_skb.h | 5 +- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 140 ++++++++++-------- src/overlays/actors/ovl_En_Horse/z_en_horse.h | 6 +- .../z_en_horse_link_child.c | 92 ++++++------ src/overlays/actors/ovl_En_Hs/z_en_hs.c | 13 +- src/overlays/actors/ovl_En_Jg/z_en_jg.c | 16 +- src/overlays/actors/ovl_En_Pr2/z_en_pr2.c | 2 +- src/overlays/actors/ovl_En_Pr2/z_en_pr2.h | 2 +- src/overlays/actors/ovl_En_Ssh/z_en_ssh.c | 2 +- src/overlays/actors/ovl_En_Ssh/z_en_ssh.h | 2 +- tools/disasm/functions.txt | 2 +- tools/disasm/variables.txt | 4 +- 25 files changed, 406 insertions(+), 290 deletions(-) diff --git a/src/overlays/actors/ovl_Boss_04/z_boss_04.c b/src/overlays/actors/ovl_Boss_04/z_boss_04.c index 82495ea1e..c35e6e9b1 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.c +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.c @@ -173,7 +173,7 @@ void Boss04_Init(Actor* thisx, PlayState* play2) { this->unk_6F8 = 1.0f; Collider_InitAndSetJntSph(play, &this->collider1, &this->actor, &sJntSphInit1, this->collider1Elements); Collider_InitAndSetJntSph(play, &this->collider2, &this->actor, &sJntSphInit2, this->collider2Elements); - SkelAnime_InitFlex(play, &this->skelAnime, &gWartSkel, &gWartIdleAnim, this->jointTable, this->morphtable, + SkelAnime_InitFlex(play, &this->skelAnime, &gWartSkel, &gWartIdleAnim, this->jointTable, this->morphTable, WART_LIMB_MAX); spA8.y = this->actor.world.pos.y + 200.0f; diff --git a/src/overlays/actors/ovl_Boss_04/z_boss_04.h b/src/overlays/actors/ovl_Boss_04/z_boss_04.h index 6aa153597..97c296b84 100644 --- a/src/overlays/actors/ovl_Boss_04/z_boss_04.h +++ b/src/overlays/actors/ovl_Boss_04/z_boss_04.h @@ -12,7 +12,7 @@ typedef struct Boss04 { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ Vec3s jointTable[WART_LIMB_MAX]; - /* 0x1BE */ Vec3s morphtable[WART_LIMB_MAX]; + /* 0x1BE */ Vec3s morphTable[WART_LIMB_MAX]; /* 0x1F4 */ s16 unk_1F4; /* 0x1F6 */ u8 unk_1F6; /* 0x1F7 */ u8 unk_1F7; diff --git a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c index 21d8bf309..4f4b15545 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.c @@ -142,7 +142,7 @@ void EnBombers_Init(Actor* thisx, PlayState* play) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f); this->actor.gravity = -1.0f; SkelAnime_InitFlex(play, &this->skelAnime, &object_cs_Skel_00F82C, &gBomberIdleAnim, this->jointTable, - this->morphtable, OBJECT_CS_LIMB_MAX); + this->morphTable, OBJECT_CS_LIMB_MAX); Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->actor.targetMode = TARGET_MODE_0; Actor_SetScale(&this->actor, 0.01f); diff --git a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h index 76013781b..500fff573 100644 --- a/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h +++ b/src/overlays/actors/ovl_En_Bombers/z_en_bombers.h @@ -25,7 +25,7 @@ typedef struct EnBombers { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ Vec3s jointTable[OBJECT_CS_LIMB_MAX]; - /* 0x206 */ Vec3s morphtable[OBJECT_CS_LIMB_MAX]; + /* 0x206 */ Vec3s morphTable[OBJECT_CS_LIMB_MAX]; /* 0x284 */ EnBombersActionFunc actionFunc; /* 0x288 */ s16 unk_288; /* 0x28A */ s16 unk_28A; diff --git a/src/overlays/actors/ovl_En_Egol/z_en_egol.c b/src/overlays/actors/ovl_En_Egol/z_en_egol.c index 30dc3de26..89ee2e5fd 100644 --- a/src/overlays/actors/ovl_En_Egol/z_en_egol.c +++ b/src/overlays/actors/ovl_En_Egol/z_en_egol.c @@ -933,7 +933,7 @@ void EnEgol_Slam(EnEgol* this, PlayState* play) { } EnEgol_DestroyBlocks(this, play, this->rightHandPos, this->leftHandPos); } - if (this->animEndFrame <= curFrame) { + if (curFrame >= this->animEndFrame) { EnEgol_SetupSlamWait(this); } else if ((this->skelAnime.curFrame <= 17.0f) && (this->skelAnime.curFrame >= 10.0f)) { CollisionCheck_SetAT(play, &play->colChkCtx, &this->bodyCollider.base); diff --git a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c index 841e6f539..85000e5cb 100644 --- a/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c +++ b/src/overlays/actors/ovl_En_Hanabi/z_en_hanabi.c @@ -194,6 +194,7 @@ void EnHanabi_Init(Actor* thisx, PlayState* play2) { EnHanabi* this = THIS; s32 i; + //! FAKE: if (1) {} Actor_SetScale(thisx, 1.0f); diff --git a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c index 83973d9e9..19c2a34a8 100644 --- a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c +++ b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.c @@ -20,14 +20,6 @@ void EnHeishi_SetHeadRotation(EnHeishi* this); void EnHeishi_SetupIdle(EnHeishi* this); void EnHeishi_Idle(EnHeishi* this, PlayState* play); -typedef enum { - /* 0 */ HEISHI_ANIM_STAND_HAND_ON_HIP, - /* 1 */ HEISHI_ANIM_CHEER_WITH_SPEAR, - /* 2 */ HEISHI_ANIM_WAVE, - /* 3 */ HEISHI_ANIM_SIT_AND_REACH, - /* 4 */ HEISHI_ANIM_STAND_UP -} EnHeishiAnimation; - ActorInit En_Heishi_InitVars = { ACTOR_EN_HEISHI, ACTORCAT_NPC, @@ -97,19 +89,36 @@ void EnHeishi_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->colliderCylinder); } +typedef enum EnHeishiAnimation { + /* 0 */ HEISHI_ANIM_STAND_HAND_ON_HIP, + /* 1 */ HEISHI_ANIM_CHEER_WITH_SPEAR, + /* 2 */ HEISHI_ANIM_WAVE, + /* 3 */ HEISHI_ANIM_SIT_AND_REACH, + /* 4 */ HEISHI_ANIM_STAND_UP, + /* 5 */ HEISHI_ANIM_MAX +} EnHeishiAnimation; + +static AnimationHeader* sAnimations[HEISHI_ANIM_MAX] = { + &gSoldierStandHandOnHip, // HEISHI_ANIM_STAND_HAND_ON_HIP + &gSoldierCheerWithSpear, // HEISHI_ANIM_CHEER_WITH_SPEAR + &gSoldierWave, // HEISHI_ANIM_WAVE + &gSoldierSitAndReach, // HEISHI_ANIM_SIT_AND_REACH + &gSoldierStandUp, // HEISHI_ANIM_STAND_UP +}; + +static u8 sAnimationModes[HEISHI_ANIM_MAX] = { + ANIMMODE_LOOP, // HEISHI_ANIM_STAND_HAND_ON_HIP + ANIMMODE_LOOP, // HEISHI_ANIM_CHEER_WITH_SPEAR + ANIMMODE_LOOP, // HEISHI_ANIM_WAVE + ANIMMODE_LOOP, // HEISHI_ANIM_SIT_AND_REACH + ANIMMODE_ONCE, // HEISHI_ANIM_STAND_UP +}; + void EnHeishi_ChangeAnim(EnHeishi* this, s32 animIndex) { - static AnimationHeader* sAnimations[] = { - &gSoldierStandHandOnHip, &gSoldierCheerWithSpear, &gSoldierWave, &gSoldierSitAndReach, &gSoldierStandUp, - }; - static u8 sAnimationModes[] = { - ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, - ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, - ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, - }; this->animIndex = animIndex; - this->frameCount = Animation_GetLastFrame(sAnimations[this->animIndex]); - Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.0f, this->frameCount, + this->animEndFrame = Animation_GetLastFrame(sAnimations[this->animIndex]); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.0f, this->animEndFrame, sAnimationModes[this->animIndex], -10.0f); } diff --git a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.h b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.h index 1758ceae6..4d886cb3c 100644 --- a/src/overlays/actors/ovl_En_Heishi/z_en_heishi.h +++ b/src/overlays/actors/ovl_En_Heishi/z_en_heishi.h @@ -25,7 +25,7 @@ typedef struct EnHeishi { /* 0x26C */ s32 shouldSetHeadRotation; /* 0x270 */ s16 timer; /* 0x272 */ s16 yawTowardsPlayer; - /* 0x274 */ f32 frameCount; + /* 0x274 */ f32 animEndFrame; /* 0x278 */ s16 unk278; // set and not used /* 0x27C */ UNK_TYPE1 unk_27C[0x8]; /* 0x284 */ ColliderCylinder colliderCylinder; diff --git a/src/overlays/actors/ovl_En_Hg/z_en_hg.c b/src/overlays/actors/ovl_En_Hg/z_en_hg.c index 2c652f11c..ded070de4 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -29,17 +29,6 @@ void EnHg_HandleCsAction(EnHg* this, PlayState* play); s32 EnHg_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); void EnHg_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); -typedef enum { - /* 0 */ HG_ANIM_IDLE, - /* 1 */ HG_ANIM_LURCH_FORWARD, - /* 2 */ HG_ANIM_RECOIL, - /* 3 */ HG_ANIM_LEAN_FORWARD, - /* 4 */ HG_ANIM_REACH_FORWARD, - /* 5 */ HG_ANIM_CURL_UP, - /* 6 */ HG_ANIM_CROUCHED_PANIC, - /* 7 */ HG_ANIM_PANIC -} HgAnimation; - typedef enum { /* 0 */ HG_CS_FIRST_ENCOUNTER, /* 1 */ HG_CS_GET_MASK, @@ -118,15 +107,27 @@ static CollisionCheckInfoInit2 sColChkInfoInit2 = { 0, 0, 0, 0, 0x80, }; -static AnimationInfo sAnimationInfo[] = { - { &gPamelasFatherIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - { &gPamelasFatherLurchForwardAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - { &gPamelasFatherRecoilFromHitAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - { &gPamelasFatherLeanForwardAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - { &gPamelasFatherReachForwardAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &gPamelasFatherCurlUpAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - { &gPamelasFatherCrouchedPanicAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &gPamelasFatherPanicAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, +typedef enum { + /* 0 */ HG_ANIM_IDLE, + /* 1 */ HG_ANIM_LURCH_FORWARD, + /* 2 */ HG_ANIM_RECOIL, + /* 3 */ HG_ANIM_LEAN_FORWARD, + /* 4 */ HG_ANIM_REACH_FORWARD, + /* 5 */ HG_ANIM_CURL_UP, + /* 6 */ HG_ANIM_CROUCHED_PANIC, + /* 7 */ HG_ANIM_PANIC, + /* 8 */ HG_ANIM_MAX +} HgAnimation; + +static AnimationInfo sAnimationInfo[HG_ANIM_MAX] = { + { &gPamelasFatherIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, // HG_ANIM_IDLE + { &gPamelasFatherLurchForwardAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, // HG_ANIM_LURCH_FORWARD + { &gPamelasFatherRecoilFromHitAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, // HG_ANIM_RECOIL + { &gPamelasFatherLeanForwardAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, // HG_ANIM_LEAN_FORWARD + { &gPamelasFatherReachForwardAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // HG_ANIM_REACH_FORWARD + { &gPamelasFatherCurlUpAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, // HG_ANIM_CURL_UP + { &gPamelasFatherCrouchedPanicAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // HG_ANIM_CROUCHED_PANIC + { &gPamelasFatherPanicAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // HG_ANIM_PANIC }; static u32 sHasSoundPlayed = false; @@ -192,7 +193,7 @@ void EnHg_ChasePlayer(EnHg* this, PlayState* play) { s32 pad; this->actor.speed = 1.6f; - if (!(player->stateFlags2 & PLAYER_STATE2_8000000) && Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { + if (!(player->stateFlags2 & PLAYER_STATE2_8000000) && (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE)) { if (((this->skelAnime.curFrame > 9.0f) && (this->skelAnime.curFrame < 16.0f)) || ((this->skelAnime.curFrame > 44.0f) && (this->skelAnime.curFrame < 51.0f))) { Actor_MoveWithGravity(&this->actor); @@ -233,7 +234,6 @@ void EnHg_ReactToHit(EnHg* this, PlayState* play) { void EnHg_HandleTatlDialog(EnHg* this, PlayState* play) { if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - // "...Sort of looks different..." Message_StartTextbox(play, 0x24F, &this->actor); } else { Actor_OfferTalk(&this->actor, play, 80.0f); @@ -295,7 +295,7 @@ void EnHg_HandleCsAction(EnHg* this, PlayState* play) { this->csIdList[3] = play->csCtx.actorCues[cueChannel]->id; switch (play->csCtx.actorCues[cueChannel]->id) { case 1: - this->animIndex = 0; + this->animIndex = HG_ANIM_IDLE; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_IDLE); break; @@ -329,6 +329,9 @@ void EnHg_HandleCsAction(EnHg* this, PlayState* play) { SET_WEEKEVENTREG(WEEKEVENTREG_75_20); Actor_Kill(&this->actor); break; + + default: + break; } } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { switch (this->animIndex) { @@ -341,6 +344,9 @@ void EnHg_HandleCsAction(EnHg* this, PlayState* play) { this->animIndex = HG_ANIM_CROUCHED_PANIC; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_CROUCHED_PANIC); break; + + default: + break; } } @@ -360,6 +366,9 @@ void EnHg_HandleCsAction(EnHg* this, PlayState* play) { Actor_PlaySfx_Flagged(&this->actor, NA_SE_EN_HALF_REDEAD_SCREAME - SFX_FLAG); } break; + + default: + break; } Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); diff --git a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c index 15bfd598b..c4d9c0371 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -38,16 +38,6 @@ typedef enum { /* 2 */ HGO_EYE_CLOSED } EyeState; -typedef enum { - /* 0 */ HGO_ANIM_ARMS_FOLDED, - /* 1 */ HGO_ANIM_ASTONISHED, - /* 2 */ HGO_ANIM_KNEEL_DOWN_AND_HUG, - /* 3 */ HGO_ANIM_CONSOLE, - /* 4 */ HGO_ANIM_CONSOLE_HEAD_UP, - /* 5 */ HGO_ANIM_REACH_DOWN_TO_LIFT, - /* 6 */ HGO_ANIM_TOSS -} HgoAnimation; - ActorInit En_Hgo_InitVars = { ACTOR_EN_HGO, ACTORCAT_NPC, @@ -60,14 +50,25 @@ ActorInit En_Hgo_InitVars = { (ActorFunc)EnHgo_Draw, }; -static AnimationInfo sAnimationInfo[] = { - { &gPamelasFatherArmsFoldedAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - { &gPamelasFatherAstonishedAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &gPamelasFatherKneelDownAndHugAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - { &gPamelasFatherConsoleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &gPamelasFatherConsoleHeadUpAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &gPamelasFatherReachDownToLiftAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - { &gPamelasFatherTossAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, +typedef enum { + /* 0 */ HGO_ANIM_ARMS_FOLDED, + /* 1 */ HGO_ANIM_ASTONISHED, + /* 2 */ HGO_ANIM_KNEEL_DOWN_AND_HUG, + /* 3 */ HGO_ANIM_CONSOLE, + /* 4 */ HGO_ANIM_CONSOLE_HEAD_UP, + /* 5 */ HGO_ANIM_REACH_DOWN_TO_LIFT, + /* 6 */ HGO_ANIM_TOSS, + /* 7 */ HGO_ANIM_MAX +} HgoAnimation; + +static AnimationInfo sAnimationInfo[HGO_ANIM_MAX] = { + { &gPamelasFatherArmsFoldedAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, // HGO_ANIM_ARMS_FOLDED + { &gPamelasFatherAstonishedAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // HGO_ANIM_ASTONISHED + { &gPamelasFatherKneelDownAndHugAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, // HGO_ANIM_KNEEL_DOWN_AND_HUG + { &gPamelasFatherConsoleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // HGO_ANIM_CONSOLE + { &gPamelasFatherConsoleHeadUpAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // HGO_ANIM_CONSOLE_HEAD_UP + { &gPamelasFatherReachDownToLiftAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, // HGO_ANIM_REACH_DOWN_TO_LIFT + { &gPamelasFatherTossAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, // HGO_ANIM_TOSS }; static ColliderCylinderInit sCylinderInit = { @@ -109,6 +110,7 @@ void EnHgo_Init(Actor* thisx, PlayState* play) { this->textId = 0; this->talkFlags = TALK_FLAG_NONE; this->isInCutscene = false; + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_75_20) || CHECK_WEEKEVENTREG(WEEKEVENTREG_CLEARED_STONE_TOWER_TEMPLE)) { EnHgo_SetupTalk(this); } else { @@ -143,7 +145,7 @@ void EnHgo_UpdateCollision(EnHgo* this, PlayState* play) { } void EnHgo_SetupTalk(EnHgo* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HGO_ANIM_ARMS_FOLDED); this->actionFunc = EnHgo_Talk; } @@ -206,6 +208,9 @@ void EnHgo_DefaultDialogueHandler(EnHgo* this, PlayState* play) { EnHgo_SetupTalk(this); } break; + + default: + break; } Math_SmoothStepToS(&this->actor.world.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x71C, 0xB6); @@ -271,6 +276,9 @@ void EnHgo_HandlePlayerChoice(EnHgo* this, PlayState* play) { Message_CloseTextbox(play); EnHgo_SetupTalk(this); break; + + default: + break; } } } @@ -285,33 +293,36 @@ s32 EnHgo_HandleCsAction(EnHgo* this, PlayState* play) { switch (play->csCtx.actorCues[cueChannel]->id) { case 1: this->animIndex = HGO_ANIM_ARMS_FOLDED; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HGO_ANIM_ARMS_FOLDED); break; case 2: this->actor.draw = EnHgo_Draw; this->animIndex = HGO_ANIM_ASTONISHED; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HGO_ANIM_ASTONISHED); break; case 3: this->animIndex = HGO_ANIM_KNEEL_DOWN_AND_HUG; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HGO_ANIM_KNEEL_DOWN_AND_HUG); break; case 4: this->animIndex = HGO_ANIM_CONSOLE; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HGO_ANIM_CONSOLE); break; case 5: this->animIndex = HGO_ANIM_CONSOLE_HEAD_UP; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HGO_ANIM_CONSOLE_HEAD_UP); break; case 6: this->animIndex = HGO_ANIM_REACH_DOWN_TO_LIFT; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 5); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HGO_ANIM_REACH_DOWN_TO_LIFT); + break; + + default: break; } } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { @@ -328,12 +339,15 @@ s32 EnHgo_HandleCsAction(EnHgo* this, PlayState* play) { case HGO_ANIM_KNEEL_DOWN_AND_HUG: this->animIndex = HGO_ANIM_CONSOLE; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HGO_ANIM_CONSOLE); break; case HGO_ANIM_REACH_DOWN_TO_LIFT: this->animIndex = HGO_ANIM_TOSS; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 6); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HGO_ANIM_TOSS); + + default: + break; } } diff --git a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c index e07dfb8a9..5d1e0ee24 100644 --- a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c +++ b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.c @@ -6,7 +6,6 @@ #include "z_en_hidden_nuts.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#include "objects/object_hintnuts/object_hintnuts.h" #define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_FRIENDLY | ACTOR_FLAG_2000000) @@ -63,15 +62,41 @@ static ColliderCylinderInit sCylinderInit = { { 30, 20, 0, { 0, 0, 0 } }, }; -static AnimationHeader* D_80BDC0FC[] = { - &object_hintnuts_Anim_000168, &object_hintnuts_Anim_0024CC, &object_hintnuts_Anim_0026C4, - &object_hintnuts_Anim_002894, &object_hintnuts_Anim_002B90, &object_hintnuts_Anim_002F7C, - &object_hintnuts_Anim_003128, &object_hintnuts_Anim_0029BC, &object_hintnuts_Anim_0024CC, +typedef enum EnHiddenNutsAnimation { + /* 0 */ ENHIDDENNUTS_ANIM_0, + /* 1 */ ENHIDDENNUTS_ANIM_1, + /* 2 */ ENHIDDENNUTS_ANIM_2, + /* 3 */ ENHIDDENNUTS_ANIM_3, + /* 4 */ ENHIDDENNUTS_ANIM_4, + /* 5 */ ENHIDDENNUTS_ANIM_5, + /* 6 */ ENHIDDENNUTS_ANIM_6, + /* 7 */ ENHIDDENNUTS_ANIM_7, + /* 8 */ ENHIDDENNUTS_ANIM_8, + /* 9 */ ENHIDDENNUTS_ANIM_MAX +} EnHiddenNutsAnimation; + +static AnimationHeader* sAnimations[ENHIDDENNUTS_ANIM_MAX] = { + &object_hintnuts_Anim_000168, // ENHIDDENNUTS_ANIM_0 + &object_hintnuts_Anim_0024CC, // ENHIDDENNUTS_ANIM_1 + &object_hintnuts_Anim_0026C4, // ENHIDDENNUTS_ANIM_2 + &object_hintnuts_Anim_002894, // ENHIDDENNUTS_ANIM_3 + &object_hintnuts_Anim_002B90, // ENHIDDENNUTS_ANIM_4 + &object_hintnuts_Anim_002F7C, // ENHIDDENNUTS_ANIM_5 + &object_hintnuts_Anim_003128, // ENHIDDENNUTS_ANIM_6 + &object_hintnuts_Anim_0029BC, // ENHIDDENNUTS_ANIM_7 + &object_hintnuts_Anim_0024CC, // ENHIDDENNUTS_ANIM_8 }; -u8 D_80BDC120[] = { - ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, - ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_LOOP, +static u8 sAnimationModes[ENHIDDENNUTS_ANIM_MAX] = { + ANIMMODE_ONCE, // ENHIDDENNUTS_ANIM_0 + ANIMMODE_ONCE, // ENHIDDENNUTS_ANIM_1 + ANIMMODE_ONCE, // ENHIDDENNUTS_ANIM_2 + ANIMMODE_LOOP, // ENHIDDENNUTS_ANIM_3 + ANIMMODE_ONCE, // ENHIDDENNUTS_ANIM_4 + ANIMMODE_LOOP, // ENHIDDENNUTS_ANIM_5 + ANIMMODE_LOOP, // ENHIDDENNUTS_ANIM_6 + ANIMMODE_ONCE, // ENHIDDENNUTS_ANIM_7 + ANIMMODE_ONCE, // ENHIDDENNUTS_ANIM_8 }; void EnHiddenNuts_Init(Actor* thisx, PlayState* play) { @@ -79,7 +104,7 @@ void EnHiddenNuts_Init(Actor* thisx, PlayState* play) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); SkelAnime_Init(play, &this->skelAnime, &object_hintnuts_Skel_0023B8.sh, &object_hintnuts_Anim_0024CC, - this->jointTable, this->morphTable, 10); + this->jointTable, this->morphTable, OBJECT_HINTNUTS_LIMB_MAX); Actor_SetScale(&this->actor, 0.01f); this->actor.colChkInfo.mass = MASS_IMMOVABLE; @@ -116,27 +141,29 @@ void EnHiddenNuts_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->collider); } -void func_80BDB1B4(EnHiddenNuts* this, s32 arg1) { - f32 sp34; - f32 sp30; +void EnHiddenNuts_ChangeAnim(EnHiddenNuts* this, s32 animIndex) { + f32 startFrame; + f32 morphFrames; - this->unk_220 = arg1; - sp34 = 0.0f; - sp30 = -4.0f; - this->unk_22C = Animation_GetLastFrame(D_80BDC0FC[arg1]); - if (this->unk_220 == 1) { - sp34 = this->unk_22C; - sp30 = 0.0f; + this->animIndex = animIndex; + startFrame = 0.0f; + morphFrames = -4.0f; + this->animEndFrame = Animation_GetLastFrame(sAnimations[animIndex]); + + if (this->animIndex == ENHIDDENNUTS_ANIM_1) { + startFrame = this->animEndFrame; + morphFrames = 0.0f; } - Animation_Change(&this->skelAnime, D_80BDC0FC[this->unk_220], 1.0f, sp34, this->unk_22C, D_80BDC120[this->unk_220], - sp30); + + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, startFrame, this->animEndFrame, + sAnimationModes[this->animIndex], morphFrames); } void func_80BDB268(EnHiddenNuts* this) { this->actor.textId = 0x234; this->unk_228 = 1600.0f; this->actor.shape.yOffset = 1600.0f; - func_80BDB1B4(this, 1); + EnHiddenNuts_ChangeAnim(this, ENHIDDENNUTS_ANIM_1); this->unk_21A = 0; this->actionFunc = func_80BDB2B8; } @@ -148,12 +175,12 @@ void func_80BDB2B8(EnHiddenNuts* this, PlayState* play) { Actor_PlaySfx(&this->actor, NA_SE_EN_NEMURI_SLEEP - SFX_FLAG); if (player->stateFlags2 & PLAYER_STATE2_8000000) { - if (this->unk_20A == 0) { + if (!this->unk_20A) { Audio_PlaySfx(NA_SE_SY_TRE_BOX_APPEAR); - this->unk_20A = 1; + this->unk_20A = true; } } else { - this->unk_20A = 0; + this->unk_20A = false; } if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { @@ -263,20 +290,20 @@ void func_80BDB7E8(EnHiddenNuts* this, PlayState* play) { EffectSsHahen_SpawnBurst(play, &sp3C, 4.0f, 0, 10, 3, 15, HAHEN_OBJECT_DEFAULT, 10, NULL); Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_UP); - func_80BDB1B4(this, 7); + EnHiddenNuts_ChangeAnim(this, ENHIDDENNUTS_ANIM_7); this->actionFunc = func_80BDB8F4; } void func_80BDB8F4(EnHiddenNuts* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; - if (this->unk_22C <= curFrame) { + if (curFrame >= this->animEndFrame) { func_80BDB930(this); } } void func_80BDB930(EnHiddenNuts* this) { - func_80BDB1B4(this, 3); + EnHiddenNuts_ChangeAnim(this, ENHIDDENNUTS_ANIM_3); this->unk_21A = 3; this->unk_228 = 500.0f; this->actionFunc = func_80BDB978; @@ -290,7 +317,7 @@ void func_80BDB978(EnHiddenNuts* this, PlayState* play) { Actor_PlaySfx(&this->actor, NA_SE_EN_NUT_FAINT); } - if (this->unk_22C <= curFrame) { + if (curFrame >= this->animEndFrame) { this->unk_224++; if (this->unk_224 >= 2) { func_80BDBA28(this, play); @@ -301,7 +328,7 @@ void func_80BDB978(EnHiddenNuts* this, PlayState* play) { void func_80BDBA28(EnHiddenNuts* this, PlayState* play) { Vec3f sp44; - func_80BDB1B4(this, 2); + EnHiddenNuts_ChangeAnim(this, ENHIDDENNUTS_ANIM_2); this->unk_228 = 0.0f; Math_Vec3f_Copy(&sp44, &this->actor.world.pos); @@ -326,10 +353,10 @@ void func_80BDBA28(EnHiddenNuts* this, PlayState* play) { void func_80BDBB48(EnHiddenNuts* this, PlayState* play) { s32 pad[3]; - f32 sp58 = this->skelAnime.curFrame; + f32 curFrame = this->skelAnime.curFrame; WaterBox* sp54; f32 sp50; - s16 sp4E = 0; + s16 sp4E = false; Vec3f sp40; if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &sp50, &sp54) && @@ -346,23 +373,23 @@ void func_80BDBB48(EnHiddenNuts* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f) || Animation_OnFrame(&this->skelAnime, 10.0f)) { Actor_PlaySfx(&this->actor, NA_SE_EV_WALK_WATER); - sp4E = 1; + sp4E = true; } } - if ((sp4E != 0) && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f) || - Animation_OnFrame(&this->skelAnime, 10.0f))) { + if (sp4E && (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 5.0f) || + Animation_OnFrame(&this->skelAnime, 10.0f))) { Actor_PlaySfx(&this->actor, NA_SE_EN_NUTS_WALK); } Math_SmoothStepToS(&this->actor.world.rot.y, Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_20C), 1, 0x1388, 0); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 1, 0x3E8, 0); - if (this->unk_220 == 2) { - if (this->unk_22C <= sp58) { + if (this->animIndex == ENHIDDENNUTS_ANIM_2) { + if (curFrame >= this->animEndFrame) { this->actor.speed = 0.0f; this->actor.velocity.y = 0.0f; - func_80BDB1B4(this, 6); + EnHiddenNuts_ChangeAnim(this, ENHIDDENNUTS_ANIM_6); } } else { Math_ApproachF(&this->actor.world.pos.x, this->unk_20C.x, 0.5f, @@ -387,7 +414,7 @@ void func_80BDBE70(EnHiddenNuts* this, PlayState* play) { if (this->switchFlag >= 0) { Flags_SetSwitch(play, this->switchFlag); } - func_80BDB1B4(this, 8); + EnHiddenNuts_ChangeAnim(this, ENHIDDENNUTS_ANIM_8); this->unk_21A = 5; this->actionFunc = func_80BDBED4; } @@ -396,7 +423,7 @@ void func_80BDBED4(EnHiddenNuts* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; Vec3f sp38; - if (this->unk_22C <= curFrame) { + if (curFrame >= this->animEndFrame) { Math_Vec3f_Copy(&sp38, &this->actor.world.pos); sp38.y = this->actor.floorHeight; diff --git a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h index 03a0a52b7..df8275aa4 100644 --- a/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h +++ b/src/overlays/actors/ovl_En_Hidden_Nuts/z_en_hidden_nuts.h @@ -2,6 +2,7 @@ #define Z_EN_HIDDEN_NUTS_H #include "global.h" +#include "objects/object_hintnuts/object_hintnuts.h" struct EnHiddenNuts; @@ -16,8 +17,8 @@ typedef void (*EnHiddenNutsActionFunc)(struct EnHiddenNuts*, PlayState*); typedef struct EnHiddenNuts { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s jointTable[10]; - /* 0x1C4 */ Vec3s morphTable[10]; + /* 0x188 */ Vec3s jointTable[OBJECT_HINTNUTS_LIMB_MAX]; + /* 0x1C4 */ Vec3s morphTable[OBJECT_HINTNUTS_LIMB_MAX]; /* 0x200 */ EnHiddenNutsActionFunc actionFunc; /* 0x204 */ Path* path; /* 0x208 */ s16 unk_208; @@ -27,11 +28,11 @@ typedef struct EnHiddenNuts { /* 0x21A */ s16 unk_21A; /* 0x21C */ s16 switchFlag; /* 0x21E */ s16 pathIndex; - /* 0x220 */ s32 unk_220; + /* 0x220 */ s32 animIndex; /* 0x224 */ s16 unk_224; /* 0x226 */ s16 csId; /* 0x228 */ f32 unk_228; - /* 0x22C */ f32 unk_22C; + /* 0x22C */ f32 animEndFrame; /* 0x230 */ UNK_TYPE1 unk230[4]; /* 0x234 */ ColliderCylinder collider; } EnHiddenNuts; // size = 0x280 diff --git a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c index 5ad3e9dcf..f9e51b55c 100644 --- a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c +++ b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.c @@ -6,7 +6,6 @@ #include "z_en_hint_skb.h" #include "overlays/effects/ovl_Effect_Ss_Hahen/z_eff_ss_hahen.h" -#include "objects/object_skb/object_skb.h" #define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_FRIENDLY | ACTOR_FLAG_10) @@ -126,20 +125,37 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0xF), }; -static AnimationInfo sAnimationInfo[] = { - { &object_skb_Anim_0064E0, 0.96f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, - { &object_skb_Anim_002190, 0.6f, 0.0f, 0.0f, ANIMMODE_ONCE_INTERP, 4.0f }, - { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, - { &object_skb_Anim_00270C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, - { &object_skb_Anim_00697C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - { &object_skb_Anim_006D90, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - { &object_skb_Anim_001D1C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, - { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -16.0f }, - { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, - { &object_skb_Anim_0015EC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, - { &object_skb_Anim_0009E4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, +typedef enum EnHinkSkbAnimation { + /* 0 */ ENHINTSKB_ANIM_0, + /* 1 */ ENHINTSKB_ANIM_1, + /* 2 */ ENHINTSKB_ANIM_2, + /* 3 */ ENHINTSKB_ANIM_3, + /* 4 */ ENHINTSKB_ANIM_4, + /* 5 */ ENHINTSKB_ANIM_5, + /* 6 */ ENHINTSKB_ANIM_6, + /* 7 */ ENHINTSKB_ANIM_7, + /* 8 */ ENHINTSKB_ANIM_8, + /* 9 */ ENHINTSKB_ANIM_9, + /* 10 */ ENHINTSKB_ANIM_10, + /* 11 */ ENHINTSKB_ANIM_11, + /* 12 */ ENHINTSKB_ANIM_12, + /* 13 */ ENHINTSKB_ANIM_MAX +} EnHinkSkbAnimation; + +static AnimationInfo sAnimationInfo[ENHINTSKB_ANIM_MAX] = { + { &object_skb_Anim_0064E0, 0.96f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, // ENHINTSKB_ANIM_0 + { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, // ENHINTSKB_ANIM_1 + { &object_skb_Anim_002190, 0.6f, 0.0f, 0.0f, ANIMMODE_ONCE_INTERP, 4.0f }, // ENHINTSKB_ANIM_2 + { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, // ENHINTSKB_ANIM_3 + { &object_skb_Anim_00270C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, // ENHINTSKB_ANIM_4 + { &object_skb_Anim_00697C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, // ENHINTSKB_ANIM_5 + { &object_skb_Anim_006D90, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, // ENHINTSKB_ANIM_6 + { &object_skb_Anim_001D1C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, // ENHINTSKB_ANIM_7 + { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, // ENHINTSKB_ANIM_8 + { &object_skb_Anim_003584, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -16.0f }, // ENHINTSKB_ANIM_9 + { &object_skb_Anim_002AC8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, // ENHINTSKB_ANIM_10 + { &object_skb_Anim_0015EC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, // ENHINTSKB_ANIM_11 + { &object_skb_Anim_0009E4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, // ENHINTSKB_ANIM_12 }; static InitChainEntry sInitChain[] = { @@ -153,7 +169,7 @@ void EnHintSkb_Init(Actor* thisx, PlayState* play) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); SkelAnime_Init(play, &this->skelAnime, &object_skb_Skel_005EF8, &object_skb_Anim_00697C, this->jointTable, - this->morphtable, 20); + this->morphTable, OBJECT_SKB_LIMB_MAX); Collider_InitJntSph(play, &this->collider); Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElement); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); @@ -181,7 +197,7 @@ void func_80C1FE20(EnHintSkb* this, PlayState* play) { } void func_80C1FE30(EnHintSkb* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENHINTSKB_ANIM_0); this->actor.speed = 1.6f; this->actionFunc = func_80C1FE80; } @@ -200,7 +216,7 @@ void func_80C1FE80(EnHintSkb* this, PlayState* play) { void func_80C1FF30(EnHintSkb* this) { this->collider.base.atFlags &= ~AT_BOUNCED; this->actor.speed = 0.0f; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENHINTSKB_ANIM_2); this->actionFunc = func_80C1FF88; } @@ -274,12 +290,12 @@ void func_80C2016C(EnHintSkb* this, PlayState* play) { void func_80C20274(EnHintSkb* this) { if (this->skelAnime.animation == &object_skb_Anim_00697C) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENHINTSKB_ANIM_8); this->actor.gravity = -1.0f; this->actor.speed = 1.0f; } else { this->actor.world.rot.y = this->actor.yawTowardsPlayer; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENHINTSKB_ANIM_3); if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->actor.speed = -4.0f; } @@ -317,7 +333,7 @@ void func_80C20334(EnHintSkb* this, PlayState* play) { } void func_80C20484(EnHintSkb* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENHINTSKB_ANIM_4); this->unk_3E8 |= 4; if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { this->actor.speed = -6.0f; @@ -349,7 +365,7 @@ void func_80C20590(EnHintSkb* this, PlayState* play) { this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENHINTSKB_ANIM_3); Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3E8 |= 1; func_80C20274(this); @@ -376,7 +392,7 @@ void func_80C2069C(EnHintSkb* this, PlayState* play) { this->drawDmgEffAlpha = 0.0f; if (this->actor.colChkInfo.health != 0) { Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENHINTSKB_ANIM_3); Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_DAMAGE); this->unk_3E8 |= 1; func_80C20274(this); @@ -405,10 +421,10 @@ void func_80C2077C(EnHintSkb* this, PlayState* play) { this->actor.speed = 2.4f; this->actor.gravity = -1.0f; this->actor.velocity.y = 3.0f; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 8); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENHINTSKB_ANIM_8); } } else { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENHINTSKB_ANIM_11); Message_StartTextbox(play, 0x1148, &this->actor); this->unk_3E6 = 0x1148; } @@ -449,6 +465,7 @@ void func_80C208D0(EnHintSkb* this, PlayState* play) { case TEXT_STATE_NONE: case TEXT_STATE_1: case TEXT_STATE_CLOSING: + default: break; } @@ -467,7 +484,7 @@ void func_80C208D0(EnHintSkb* this, PlayState* play) { Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { Message_StartTextbox(play, 0x1147, &this->actor); this->unk_3E6 = 0x1147; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENHINTSKB_ANIM_0); } } @@ -542,7 +559,7 @@ void func_80C20C24(EnHintSkb* this, PlayState* play) { case 0x1147: Message_StartTextbox(play, 0x1148, &this->actor); this->unk_3E6 = 0x1148; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 11); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENHINTSKB_ANIM_11); break; case 0x1148: @@ -578,6 +595,9 @@ void func_80C20C24(EnHintSkb* this, PlayState* play) { func_80C2075C(this); } break; + + default: + break; } } @@ -591,7 +611,7 @@ void func_80C20D64(EnHintSkb* this, PlayState* play) { this->actor.hintId = TATL_HINT_ID_NONE; this->actor.textId = 0; if (this->actionFunc == func_80C1FE80) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 12); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENHINTSKB_ANIM_12); } func_80C2075C(this); } @@ -682,6 +702,7 @@ void func_80C20E90(EnHintSkb* this, PlayState* play) { this->unk_3E8 |= 1; func_80C20274(this); break; + case 3: if (this->actor.colChkInfo.health != 0) { Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_DAMAGE); @@ -695,6 +716,7 @@ void func_80C20E90(EnHintSkb* this, PlayState* play) { Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); func_80C20540(this); break; + case 4: this->drawDmgEffTimer = 40; this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; @@ -702,14 +724,14 @@ void func_80C20E90(EnHintSkb* this, PlayState* play) { this->drawDmgEffScale = 0.5f; Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENHINTSKB_ANIM_3); func_80C2066C(this); break; case 12: case 14: this->unk_3E8 |= 1; - + // fallthrough case 15: if ((player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_SLASH_1H) || (player->meleeWeaponAnimation == PLAYER_MWA_LEFT_COMBO_2H) || @@ -717,11 +739,11 @@ void func_80C20E90(EnHintSkb* this, PlayState* play) { (player->meleeWeaponAnimation == PLAYER_MWA_BACKSLASH_LEFT)) { this->unk_3E8 |= 1; } - + // fallthrough case 13: Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, 8); Actor_PlaySfx(&this->actor, NA_SE_EN_STALKID_DAMAGE); - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENHINTSKB_ANIM_3); func_80C20274(this); break; @@ -731,6 +753,7 @@ void func_80C20E90(EnHintSkb* this, PlayState* play) { case 8: case 9: case 10: + default: break; } } @@ -850,7 +873,7 @@ s32 EnHintSkb_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3 EnHintSkb* this = THIS; f32 temp_f10; - if (limbIndex == 11) { + if (limbIndex == OBJECT_SKB_LIMB_0B) { OPEN_DISPS(play->state.gfxCtx); temp_f10 = fabsf(Math_SinS(play->state.frames * 6000) * 95.0f) + 160.0f; @@ -859,13 +882,13 @@ s32 EnHintSkb_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3 gDPSetEnvColor(POLY_OPA_DISP++, (s16)temp_f10, (s16)temp_f10, (s16)temp_f10, 255); CLOSE_DISPS(play->state.gfxCtx); - } else if (limbIndex == 10) { + } else if (limbIndex == OBJECT_SKB_LIMB_0A) { Matrix_MultZero(&this->actor.focus.pos); - } else if ((limbIndex == 12) && (this->unk_3DE == 1)) { + } else if ((limbIndex == OBJECT_SKB_LIMB_0C) && (this->unk_3DE == 1)) { Matrix_RotateZS(0x71C, MTXMODE_APPLY); } - if (((limbIndex == 11) || (limbIndex == 12)) && (this->unk_3E8 & 2)) { + if (((limbIndex == OBJECT_SKB_LIMB_0B) || (limbIndex == OBJECT_SKB_LIMB_0C)) && (this->unk_3E8 & 2)) { *dList = NULL; } @@ -879,21 +902,25 @@ void EnHintSkb_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* if (!(this->unk_3E8 & 8)) { Collider_UpdateSpheres(limbIndex, &this->collider); - if ((limbIndex == 11) && (this->unk_3E8 & 1) && !(this->unk_3E8 & 2)) { + if ((limbIndex == OBJECT_SKB_LIMB_0B) && (this->unk_3E8 & 1) && !(this->unk_3E8 & 2)) { Actor_SpawnBodyParts(&this->actor, play, 1, dList); this->unk_3E8 |= 2; - } else if ((this->unk_3E8 & 4) && !(this->unk_3E8 & 8) && ((limbIndex != 11) || !(this->unk_3E8 & 1)) && - (limbIndex != 12)) { + } else if ((this->unk_3E8 & 4) && !(this->unk_3E8 & 8) && + ((limbIndex != OBJECT_SKB_LIMB_0B) || !(this->unk_3E8 & 1)) && (limbIndex != OBJECT_SKB_LIMB_0C)) { Actor_SpawnBodyParts(&this->actor, play, 1, dList); } if (this->drawDmgEffTimer != 0) { - if ((limbIndex == 2) || (limbIndex == 4) || (limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || - (limbIndex == 8) || (limbIndex == 9) || (limbIndex == 13) || (limbIndex == 14) || (limbIndex == 15) || - (limbIndex == 16) || (limbIndex == 17) || (limbIndex == 18)) { + if ((limbIndex == OBJECT_SKB_LIMB_02) || (limbIndex == OBJECT_SKB_LIMB_04) || + (limbIndex == OBJECT_SKB_LIMB_05) || (limbIndex == OBJECT_SKB_LIMB_06) || + (limbIndex == OBJECT_SKB_LIMB_07) || (limbIndex == OBJECT_SKB_LIMB_08) || + (limbIndex == OBJECT_SKB_LIMB_09) || (limbIndex == OBJECT_SKB_LIMB_0D) || + (limbIndex == OBJECT_SKB_LIMB_0E) || (limbIndex == OBJECT_SKB_LIMB_0F) || + (limbIndex == OBJECT_SKB_LIMB_10) || (limbIndex == OBJECT_SKB_LIMB_11) || + (limbIndex == OBJECT_SKB_LIMB_12)) { Matrix_MultZero(&this->bodyPartsPos[this->bodyPartsCount]); this->bodyPartsCount++; - } else if ((limbIndex == 11) && !(this->unk_3E8 & 2)) { + } else if ((limbIndex == OBJECT_SKB_LIMB_0B) && !(this->unk_3E8 & 2)) { Matrix_MultVec3f(&D_80C21E70, &this->bodyPartsPos[this->bodyPartsCount]); this->bodyPartsCount++; } diff --git a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h index e263b9de0..95576210d 100644 --- a/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h +++ b/src/overlays/actors/ovl_En_Hint_Skb/z_en_hint_skb.h @@ -2,6 +2,7 @@ #define Z_EN_HINT_SKB_H #include "global.h" +#include "objects/object_skb/object_skb.h" struct EnHintSkb; @@ -37,8 +38,8 @@ typedef struct EnHintSkb { /* 0x2D4 */ f32 drawDmgEffAlpha; /* 0x2D8 */ f32 drawDmgEffScale; /* 0x2DC */ s32 bodyPartsCount; - /* 0x2E0 */ Vec3s jointTable[20]; - /* 0x358 */ Vec3s morphtable[20]; + /* 0x2E0 */ Vec3s jointTable[OBJECT_SKB_LIMB_MAX]; + /* 0x358 */ Vec3s morphTable[OBJECT_SKB_LIMB_MAX]; /* 0x3D0 */ UNK_TYPE1 unk3D0[0xC]; /* 0x3DC */ s16 unk_3DC; /* 0x3DE */ s16 unk_3DE; diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index 00a5fd3b1..fe386b2ff 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -40,10 +40,10 @@ void EnHorse_StartReversing(EnHorse* this); void EnHorse_StartLowJump(EnHorse* this, PlayState* play); void EnHorse_StartHighJump(EnHorse* this, PlayState* play); void EnHorse_InitInactive(EnHorse* this); -void EnHorse_ChangeIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames); +void EnHorse_ChangeIdleAnimation(EnHorse* this, s32 animIndex, f32 morphFrames); void EnHorse_ResetIdleAnimation(EnHorse* this); void EnHorse_StartIdleRidable(EnHorse* this); -void EnHorse_StartMovingAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 startFrames); +void EnHorse_StartMovingAnimation(EnHorse* this, s32 animIndex, f32 morphFrames, f32 startFrames); void EnHorse_SetFollowAnimation(EnHorse* this, PlayState* play); void EnHorse_InitIngoHorse(EnHorse* this); void EnHorse_UpdateIngoHorseAnim(EnHorse* this); @@ -109,33 +109,56 @@ typedef struct { /* 0x4 */ RaceWaypoint* waypoints; } RaceInfo; // size = 0x8 -static AnimationHeader* sEponaAnimations[] = { - &gEponaIdleAnim, - &gEponaWhinnyAnim, - &object_horse_link_child_Anim_005F64, - &object_horse_link_child_Anim_004DE8, - &gEponaWalkAnim, - &gEponaTrotAnim, - &gEponaGallopAnim, - &object_horse_link_child_Anim_0035B0, - &object_horse_link_child_Anim_003D38, +static AnimationHeader* sEponaAnimations[ENHORSE_ANIM_MAX] = { + &gEponaIdleAnim, // ENHORSE_ANIM_IDLE + &gEponaWhinnyAnim, // ENHORSE_ANIM_WHINNY + &object_horse_link_child_Anim_005F64, // ENHORSE_ANIM_STOPPING + &object_horse_link_child_Anim_004DE8, // ENHORSE_ANIM_REARING + &gEponaWalkAnim, // ENHORSE_ANIM_WALK + &gEponaTrotAnim, // ENHORSE_ANIM_TROT + &gEponaGallopAnim, // ENHORSE_ANIM_GALLOP + &object_horse_link_child_Anim_0035B0, // ENHORSE_ANIM_LOW_JUMP + &object_horse_link_child_Anim_003D38, // ENHORSE_ANIM_HIGH_JUMP }; -static AnimationHeader* sHniAnimations[] = { - &gHorseIdleAnim, &gHorseShakeHeadAnim, &gHorseStopAnim, &gHorseWhinnyAnim, &gHorseWalkAnim, - &gHorseTrotAnim, &gHorseGallopAnim, &gHorseJumpLowAnim, &gHorseJumpHighAnim, +static AnimationHeader* sHniAnimations[ENHORSE_ANIM_MAX] = { + &gHorseIdleAnim, // ENHORSE_ANIM_IDLE + &gHorseShakeHeadAnim, // ENHORSE_ANIM_WHINNY + &gHorseStopAnim, // ENHORSE_ANIM_STOPPING + &gHorseWhinnyAnim, // ENHORSE_ANIM_REARING @TODO: Does not line up + &gHorseWalkAnim, // ENHORSE_ANIM_WALK + &gHorseTrotAnim, // ENHORSE_ANIM_TROT + &gHorseGallopAnim, // ENHORSE_ANIM_GALLOP + &gHorseJumpLowAnim, // ENHORSE_ANIM_LOW_JUMP + &gHorseJumpHighAnim, // ENHORSE_ANIM_HIGH_JUMP }; -static AnimationHeader** sAnimationHeaders[] = { - NULL, NULL, sEponaAnimations, sHniAnimations, sHniAnimations, +static AnimationHeader** sAnimationHeaders[HORSE_TYPE_MAX] = { + NULL, // HORSE_TYPE_EPONA + NULL, // HORSE_TYPE_HNI + sEponaAnimations, // HORSE_TYPE_2 + sHniAnimations, // HORSE_TYPE_BANDIT + sHniAnimations, // HORSE_TYPE_DONKEY }; -static f32 sPlaybackSpeeds[] = { - 2.0f / 3.0f, 2.0f / 3.0f, 3.0f / 3.0f, 3.0f / 3.0f, 3.0f / 3.0f, 3.0f / 3.0f, 3.0f / 3.0f, 2.0f / 3.0f, 2.0f / 3.0f, +static f32 sPlaybackSpeeds[ENHORSE_ANIM_MAX] = { + 2.0f / 3.0f, // ENHORSE_ANIM_IDLE + 2.0f / 3.0f, // ENHORSE_ANIM_WHINNY + 3.0f / 3.0f, // ENHORSE_ANIM_STOPPING + 3.0f / 3.0f, // ENHORSE_ANIM_REARING + 3.0f / 3.0f, // ENHORSE_ANIM_WALK + 3.0f / 3.0f, // ENHORSE_ANIM_TROT + 3.0f / 3.0f, // ENHORSE_ANIM_GALLOP + 2.0f / 3.0f, // ENHORSE_ANIM_LOW_JUMP + 2.0f / 3.0f, // ENHORSE_ANIM_HIGH_JUMP }; -static SkeletonHeader* sSkeletonHeaders[] = { - NULL, NULL, &gEponaSkel, NULL, NULL, +static SkeletonHeader* sSkeletonHeaders[HORSE_TYPE_MAX] = { + NULL, // HORSE_TYPE_EPONA + NULL, // HORSE_TYPE_HNI + &gEponaSkel, // HORSE_TYPE_2 + NULL, // HORSE_TYPE_BANDIT + NULL, // HORSE_TYPE_DONKEY }; ActorInit En_Horse_InitVars = { @@ -570,7 +593,8 @@ void EnHorse_IdleAnimSounds(EnHorse* this, PlayState* play) { } else { Audio_PlaySfx_AtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_SANDDUST); } - } else if ((this->animIndex == 3) && (this->curFrame > 25.0f) && !(this->stateFlags & ENHORSE_LAND2_SOUND)) { + } else if ((this->animIndex == ENHORSE_ANIM_REARING) && (this->curFrame > 25.0f) && + !(this->stateFlags & ENHORSE_LAND2_SOUND)) { this->stateFlags |= ENHORSE_LAND2_SOUND; if (this->type == HORSE_TYPE_2) { Audio_PlaySfx_AtPos(&this->actor.projectedPos, NA_SE_EV_KID_HORSE_LAND2); @@ -836,7 +860,7 @@ void EnHorse_Init(Actor* thisx, PlayState* play2) { Skin_Init(&play->state, &this->skin, sSkeletonHeaders[this->type], sAnimationHeaders[this->type][0]); } - this->animIndex = 0; + this->animIndex = ENHORSE_ANIM_IDLE; this->numBoosts = 6; this->boostRegenTime = 0; this->postDrawFunc = NULL; @@ -1900,21 +1924,21 @@ void EnHorse_Inactive(EnHorse* this, PlayState* play) { } } -void EnHorse_PlayIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 startFrames) { +void EnHorse_PlayIdleAnimation(EnHorse* this, s32 animIndex, f32 morphFrames, f32 startFrames) { this->action = ENHORSE_ACTION_IDLE; this->actor.speed = 0.0f; - if ((anim != ENHORSE_ANIM_IDLE) && (anim != ENHORSE_ANIM_WHINNY) && (anim != ENHORSE_ANIM_REARING)) { - anim = ENHORSE_ANIM_IDLE; + if ((animIndex != ENHORSE_ANIM_IDLE) && (animIndex != ENHORSE_ANIM_WHINNY) && (animIndex != ENHORSE_ANIM_REARING)) { + animIndex = ENHORSE_ANIM_IDLE; } - if (sAnimationHeaders[this->type][anim] == NULL) { - anim = ENHORSE_ANIM_IDLE; + if (sAnimationHeaders[this->type][animIndex] == NULL) { + animIndex = ENHORSE_ANIM_IDLE; } - if (anim != this->animIndex) { - this->animIndex = anim; - if (anim == ENHORSE_ANIM_IDLE) { + if (this->animIndex != animIndex) { + this->animIndex = animIndex; + if (animIndex == ENHORSE_ANIM_IDLE) { this->stateFlags &= ~ENHORSE_SANDDUST_SOUND; } else { if (this->animIndex == ENHORSE_ANIM_WHINNY) { @@ -1942,8 +1966,8 @@ void EnHorse_PlayIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 sta } } -void EnHorse_ChangeIdleAnimation(EnHorse* this, s32 anim, f32 morphFrames) { - EnHorse_PlayIdleAnimation(this, anim, morphFrames, this->curFrame); +void EnHorse_ChangeIdleAnimation(EnHorse* this, s32 animIndex, f32 morphFrames) { + EnHorse_PlayIdleAnimation(this, animIndex, morphFrames, this->curFrame); } void EnHorse_ResetIdleAnimation(EnHorse* this) { @@ -1999,16 +2023,16 @@ void EnHorse_Idle(EnHorse* this, PlayState* play) { } } -void EnHorse_StartMovingAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 startFrames) { +void EnHorse_StartMovingAnimation(EnHorse* this, s32 animIndex, f32 morphFrames, f32 startFrames) { this->action = ENHORSE_ACTION_FOLLOW_PLAYER; this->stateFlags &= ~ENHORSE_TURNING_TO_PLAYER; - if ((anim != ENHORSE_ANIM_TROT) && (anim != ENHORSE_ANIM_GALLOP) && (anim != ENHORSE_ANIM_WALK)) { - anim = ENHORSE_ANIM_WALK; + if ((animIndex != ENHORSE_ANIM_TROT) && (animIndex != ENHORSE_ANIM_GALLOP) && (animIndex != ENHORSE_ANIM_WALK)) { + animIndex = ENHORSE_ANIM_WALK; } - if (anim != this->animIndex) { - this->animIndex = anim; + if (this->animIndex != animIndex) { + this->animIndex = animIndex; Animation_Change(&this->skin.skelAnime, sAnimationHeaders[this->type][this->animIndex], 1.0f, startFrames, Animation_GetLastFrame(sAnimationHeaders[this->type][this->animIndex]), ANIMMODE_ONCE, morphFrames); @@ -2019,38 +2043,38 @@ void EnHorse_StartMovingAnimation(EnHorse* this, s32 anim, f32 morphFrames, f32 } void EnHorse_SetFollowAnimation(EnHorse* this, PlayState* play) { - s32 anim = ENHORSE_ANIM_WALK; + s32 animIndex = ENHORSE_ANIM_WALK; f32 distToPlayer = Actor_WorldDistXZToActor(&this->actor, &GET_PLAYER(play)->actor); if (distToPlayer > 400.0f) { - anim = ENHORSE_ANIM_GALLOP; + animIndex = ENHORSE_ANIM_GALLOP; } else if (!(distToPlayer <= 300.0f) && (distToPlayer <= 400.0f)) { - anim = ENHORSE_ANIM_TROT; + animIndex = ENHORSE_ANIM_TROT; } if (this->animIndex == ENHORSE_ANIM_GALLOP) { if (distToPlayer > 400.0f) { - anim = ENHORSE_ANIM_GALLOP; + animIndex = ENHORSE_ANIM_GALLOP; } else { - anim = ENHORSE_ANIM_TROT; + animIndex = ENHORSE_ANIM_TROT; } } else if (this->animIndex == ENHORSE_ANIM_TROT) { if (distToPlayer > 400.0f) { - anim = ENHORSE_ANIM_GALLOP; + animIndex = ENHORSE_ANIM_GALLOP; } else if (distToPlayer < 300.0f) { - anim = ENHORSE_ANIM_WALK; + animIndex = ENHORSE_ANIM_WALK; } else { - anim = ENHORSE_ANIM_TROT; + animIndex = ENHORSE_ANIM_TROT; } } else if (this->animIndex == ENHORSE_ANIM_WALK) { if (distToPlayer > 300.0f) { - anim = ENHORSE_ANIM_TROT; + animIndex = ENHORSE_ANIM_TROT; } else { - anim = ENHORSE_ANIM_WALK; + animIndex = ENHORSE_ANIM_WALK; } } - EnHorse_StartMovingAnimation(this, anim, -3.0f, 0.0f); + EnHorse_StartMovingAnimation(this, animIndex, -3.0f, 0.0f); } void EnHorse_FollowPlayer(EnHorse* this, PlayState* play) { @@ -2155,7 +2179,7 @@ void EnHorse_InitIngoHorse(EnHorse* this) { void EnHorse_SetIngoAnimation(s32 animIndex, f32 curFrame, s32 arg2, s16* animIndexOut) { *animIndexOut = sIngoAnimIndices[animIndex]; - if (arg2 == ENIN_ANIM_1) { + if (arg2 == 1) { if (animIndex == ENHORSE_ANIM_TROT) { *animIndexOut = ENIN_ANIM_4; } else if (animIndex == ENHORSE_ANIM_GALLOP) { @@ -2286,7 +2310,7 @@ void func_80881290(EnHorse* this, PlayState* play) { void func_80881398(EnHorse* this, PlayState* play) { Vec3s* jointTable; f32 y; - s32 animeUpdated; + s32 isAnimFinished; f32 curFrame; this->stateFlags |= ENHORSE_JUMPING; @@ -2294,7 +2318,7 @@ void func_80881398(EnHorse* this, PlayState* play) { this->actor.speed = 14.0f; } - animeUpdated = SkelAnime_Update(&this->skin.skelAnime); + isAnimFinished = SkelAnime_Update(&this->skin.skelAnime); curFrame = this->skin.skelAnime.curFrame; if (curFrame > 23.0f) { @@ -2313,8 +2337,8 @@ void func_80881398(EnHorse* this, PlayState* play) { this->actor.world.pos.y = this->jumpStartY + (y * 0.01f * this->unk_528 * 0.01f); } - if (animeUpdated || ((curFrame > 17.0f) && - (this->actor.world.pos.y < ((this->actor.floorHeight - this->actor.velocity.y) + 80.0f)))) { + if (isAnimFinished || ((curFrame > 17.0f) && + (this->actor.world.pos.y < ((this->actor.floorHeight - this->actor.velocity.y) + 80.0f)))) { if (this->type == HORSE_TYPE_2) { Audio_PlaySfx_AtPos(&this->actor.projectedPos, NA_SE_EV_HORSE_LAND); } else { @@ -2962,7 +2986,7 @@ void EnHorse_FleePlayer(EnHorse* this, PlayState* play) { f32 playerDistToHome; f32 distToPlayer; s32 nextAnimIndex = this->animIndex; - s32 animFinished; + s32 isAnimFinished; s16 yaw; if (gHorsePlayedEponasSong || (this->type == HORSE_TYPE_HNI)) { @@ -3041,7 +3065,7 @@ void EnHorse_FleePlayer(EnHorse* this, PlayState* play) { this->actor.shape.rot.y = this->actor.world.rot.y; } - animFinished = SkelAnime_Update(&this->skin.skelAnime); + isAnimFinished = SkelAnime_Update(&this->skin.skelAnime); if (((this->animIndex == ENHORSE_ANIM_IDLE) || (this->animIndex == ENHORSE_ANIM_WHINNY)) && ((nextAnimIndex == ENHORSE_ANIM_GALLOP) || (nextAnimIndex == ENHORSE_ANIM_TROT) || @@ -3054,7 +3078,7 @@ void EnHorse_FleePlayer(EnHorse* this, PlayState* play) { } else if (this->animIndex == ENHORSE_ANIM_TROT) { func_8087C178(this); } - } else if (animFinished) { + } else if (isAnimFinished) { if (nextAnimIndex == ENHORSE_ANIM_GALLOP) { func_8087C1C0(this); } else if (nextAnimIndex == ENHORSE_ANIM_TROT) { @@ -3499,7 +3523,7 @@ void EnHorse_ObstructMovement(EnHorse* this, PlayState* play, s32 obstacleType, this->actor.world.pos = this->lastPos; this->stateFlags |= ENHORSE_OBSTACLE; if (this->playerControlled == 0) { - if (this->animIndex != 3) {} + if (this->animIndex != ENHORSE_ANIM_REARING) {} } else if (this->action != ENHORSE_ACTION_MOUNTED_REARING) { if (this->stateFlags & ENHORSE_JUMPING) { this->stateFlags &= ~ENHORSE_JUMPING; diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.h b/src/overlays/actors/ovl_En_Horse/z_en_horse.h index 75f0254fc..f3c868c85 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.h +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.h @@ -93,7 +93,8 @@ typedef enum EnHorseAnimation { /* 5 */ ENHORSE_ANIM_TROT, /* 6 */ ENHORSE_ANIM_GALLOP, /* 7 */ ENHORSE_ANIM_LOW_JUMP, - /* 8 */ ENHORSE_ANIM_HIGH_JUMP + /* 8 */ ENHORSE_ANIM_HIGH_JUMP, + /* 9 */ ENHORSE_ANIM_MAX } EnHorseAnimation; typedef enum HorseType { @@ -101,7 +102,8 @@ typedef enum HorseType { /* 1 */ HORSE_TYPE_HNI, /* 2 */ HORSE_TYPE_2, /* 3 */ HORSE_TYPE_BANDIT, - /* 4 */ HORSE_TYPE_DONKEY // Cremia's donkey + /* 4 */ HORSE_TYPE_DONKEY, // Cremia's donkey + /* 5 */ HORSE_TYPE_MAX } HorseType; #define ENHORSE_PARAM_BANDIT 0x2000 diff --git a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c index bba55073b..78d6f8624 100644 --- a/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c +++ b/src/overlays/actors/ovl_En_Horse_Link_Child/z_en_horse_link_child.c @@ -19,7 +19,7 @@ void EnHorseLinkChild_Update(Actor* thisx, PlayState* play); void EnHorseLinkChild_Draw(Actor* thisx, PlayState* play); void EnHorseLinkChild_ActionFunc0(EnHorseLinkChild* this, PlayState* play); -void EnHorseLinkChild_SetupWaitForPlayer(EnHorseLinkChild* this, s32 nextAnimIndex); +void EnHorseLinkChild_SetupWaitForPlayer(EnHorseLinkChild* this, s32 animIndex); void EnHorseLinkChild_WaitForPlayer(EnHorseLinkChild* this, PlayState* play); void EnHorseLinkChild_SetupGreetPlayer(EnHorseLinkChild* this); void EnHorseLinkChild_GreetPlayer(EnHorseLinkChild* this, PlayState* play); @@ -51,7 +51,7 @@ typedef enum { /* 5 */ OOT_CHILD_EPONA_ANIM_MAX } OoTEponaAnimation; -AnimationHeader* sAnimations[OOT_CHILD_EPONA_ANIM_MAX] = { +static AnimationHeader* sAnimations[OOT_CHILD_EPONA_ANIM_MAX] = { &gEponaIdleAnim, // OOT_CHILD_EPONA_ANIM_IDLE &gEponaWhinnyAnim, // OOT_CHILD_EPONA_ANIM_WHINNY &gEponaWalkAnim, // OOT_CHILD_EPONA_ANIM_WALK @@ -221,7 +221,7 @@ void EnHorseLinkChild_Destroy(Actor* thisx, PlayState* play) { void EnHorseLinkChild_SetupActionFunc0(EnHorseLinkChild* this) { this->action = OOT_CHILD_EPONA_ACTION_0; this->animIndex++; - if (this->animIndex >= ARRAY_COUNT(sAnimPlaySpeeds)) { + if (this->animIndex >= OOT_CHILD_EPONA_ANIM_MAX) { this->animIndex = OOT_CHILD_EPONA_ANIM_IDLE; } Animation_PlayOnce(&this->skin.skelAnime, sAnimations[this->animIndex]); @@ -238,16 +238,16 @@ void EnHorseLinkChild_ActionFunc0(EnHorseLinkChild* this, PlayState* play) { } } -void EnHorseLinkChild_SetupWaitForPlayer(EnHorseLinkChild* this, s32 nextAnimIndex) { +void EnHorseLinkChild_SetupWaitForPlayer(EnHorseLinkChild* this, s32 animIndex) { this->action = OOT_CHILD_EPONA_ACTION_WAIT_FOR_PLAYER; this->actor.speed = 0.0f; - if ((nextAnimIndex != OOT_CHILD_EPONA_ANIM_IDLE) && (nextAnimIndex != OOT_CHILD_EPONA_ANIM_WHINNY)) { - nextAnimIndex = OOT_CHILD_EPONA_ANIM_IDLE; + if ((animIndex != OOT_CHILD_EPONA_ANIM_IDLE) && (animIndex != OOT_CHILD_EPONA_ANIM_WHINNY)) { + animIndex = OOT_CHILD_EPONA_ANIM_IDLE; } - if (nextAnimIndex != this->animIndex) { - this->animIndex = nextAnimIndex; + if (this->animIndex != animIndex) { + this->animIndex = animIndex; Animation_Change(&this->skin.skelAnime, sAnimations[this->animIndex], EnHorseLinkChild_GetAnimSpeed(this), 0.0f, Animation_GetLastFrame(sAnimations[this->animIndex]), ANIMMODE_ONCE, -5.0f); } @@ -258,7 +258,7 @@ void EnHorseLinkChild_SetupWaitForPlayer(EnHorseLinkChild* this, s32 nextAnimInd */ void EnHorseLinkChild_WaitForPlayer(EnHorseLinkChild* this, PlayState* play) { f32 distToPlayer = Actor_WorldDistXZToActor(&this->actor, &GET_PLAYER(play)->actor); - s32 nextAnimIndex; + s32 animIndex; if (SkelAnime_Update(&this->skin.skelAnime)) { if ((distToPlayer < 1000.0f) && (distToPlayer > 70.0f)) { @@ -267,13 +267,13 @@ void EnHorseLinkChild_WaitForPlayer(EnHorseLinkChild* this, PlayState* play) { } if (this->animIndex == OOT_CHILD_EPONA_ANIM_WHINNY) { - nextAnimIndex = OOT_CHILD_EPONA_ANIM_IDLE; + animIndex = OOT_CHILD_EPONA_ANIM_IDLE; } else { - nextAnimIndex = OOT_CHILD_EPONA_ANIM_WHINNY; + animIndex = OOT_CHILD_EPONA_ANIM_WHINNY; } - if (nextAnimIndex != this->animIndex) { - this->animIndex = nextAnimIndex; + if (this->animIndex != animIndex) { + this->animIndex = animIndex; Animation_Change(&this->skin.skelAnime, sAnimations[this->animIndex], EnHorseLinkChild_GetAnimSpeed(this), 0.0f, Animation_GetLastFrame(sAnimations[this->animIndex]), ANIMMODE_ONCE, -5.0f); } else { @@ -297,7 +297,7 @@ void EnHorseLinkChild_SetupGreetPlayer(EnHorseLinkChild* this) { void EnHorseLinkChild_GreetPlayer(EnHorseLinkChild* this, PlayState* play) { f32 distToPlayer; s16 yawTowardPlayerDiff; - s32 nextAnimIndex; + s32 animIndex; if ((this->animIndex == OOT_CHILD_EPONA_ANIM_GALLOP) || (this->animIndex == OOT_CHILD_EPONA_ANIM_TROT) || (this->animIndex == OOT_CHILD_EPONA_ANIM_WALK)) { @@ -321,13 +321,13 @@ void EnHorseLinkChild_GreetPlayer(EnHorseLinkChild* this, PlayState* play) { } if ((distToPlayer < 1000.0f) && (distToPlayer >= 300.0f)) { - nextAnimIndex = OOT_CHILD_EPONA_ANIM_GALLOP; + animIndex = OOT_CHILD_EPONA_ANIM_GALLOP; this->actor.speed = 6.0f; } else if ((distToPlayer < 300.0f) && (distToPlayer >= 150.0f)) { - nextAnimIndex = OOT_CHILD_EPONA_ANIM_TROT; + animIndex = OOT_CHILD_EPONA_ANIM_TROT; this->actor.speed = 4.0f; } else if ((distToPlayer < 150.0f) && (distToPlayer >= 70.0f)) { - nextAnimIndex = OOT_CHILD_EPONA_ANIM_WALK; + animIndex = OOT_CHILD_EPONA_ANIM_WALK; this->footstepCounter = 0; this->actor.speed = 2.0f; } else { @@ -335,8 +335,8 @@ void EnHorseLinkChild_GreetPlayer(EnHorseLinkChild* this, PlayState* play) { return; } - if (nextAnimIndex != this->animIndex) { - this->animIndex = nextAnimIndex; + if (this->animIndex != animIndex) { + this->animIndex = animIndex; Animation_Change(&this->skin.skelAnime, sAnimations[this->animIndex], EnHorseLinkChild_GetAnimSpeed(this), 0.0f, Animation_GetLastFrame(sAnimations[this->animIndex]), ANIMMODE_ONCE, -5.0f); } else { @@ -394,16 +394,16 @@ void EnHorseLinkChild_LonLonIdle(EnHorseLinkChild* this, PlayState* play) { Player* player; f32 distToPlayer; s32 isAnimFinished; - s32 nextAnimIndex; + s32 animIndex; func_808DF088(this, play); player = GET_PLAYER(play); distToPlayer = Actor_WorldDistXZToActor(&this->actor, &player->actor); - nextAnimIndex = this->animIndex; + animIndex = this->animIndex; isAnimFinished = SkelAnime_Update(&this->skin.skelAnime); - if ((isAnimFinished) || (this->animIndex == OOT_CHILD_EPONA_ANIM_WHINNY) || + if (isAnimFinished || (this->animIndex == OOT_CHILD_EPONA_ANIM_WHINNY) || (this->animIndex == OOT_CHILD_EPONA_ANIM_IDLE)) { //! @bug: The carry-over of this flag from OoT was not done correctly if (CHECK_WEEKEVENTREG(WEEKEVENTREG_ENTERED_ZORA_HALL)) { @@ -412,55 +412,53 @@ void EnHorseLinkChild_LonLonIdle(EnHorseLinkChild* this, PlayState* play) { if (Math3D_Distance(&player->actor.world.pos, &this->actor.home.pos) > 250.0f) { if (distToHome >= 300.0f) { - nextAnimIndex = OOT_CHILD_EPONA_ANIM_GALLOP; + animIndex = OOT_CHILD_EPONA_ANIM_GALLOP; this->actor.speed = 6.0f; } else if ((distToHome < 300.0f) && (distToHome >= 150.0f)) { - nextAnimIndex = OOT_CHILD_EPONA_ANIM_TROT; + animIndex = OOT_CHILD_EPONA_ANIM_TROT; this->actor.speed = 4.0f; } else if ((distToHome < 150.0f) && (distToHome >= 70.0f)) { - nextAnimIndex = OOT_CHILD_EPONA_ANIM_WALK; + animIndex = OOT_CHILD_EPONA_ANIM_WALK; this->footstepCounter = 0; this->actor.speed = 2.0f; } else { this->actor.speed = 0.0f; if (this->animIndex == OOT_CHILD_EPONA_ANIM_IDLE) { - nextAnimIndex = - (isAnimFinished == true) ? OOT_CHILD_EPONA_ANIM_WHINNY : OOT_CHILD_EPONA_ANIM_IDLE; + animIndex = (isAnimFinished == true) ? OOT_CHILD_EPONA_ANIM_WHINNY : OOT_CHILD_EPONA_ANIM_IDLE; } else { - nextAnimIndex = - (isAnimFinished == true) ? OOT_CHILD_EPONA_ANIM_IDLE : OOT_CHILD_EPONA_ANIM_WHINNY; + animIndex = (isAnimFinished == true) ? OOT_CHILD_EPONA_ANIM_IDLE : OOT_CHILD_EPONA_ANIM_WHINNY; } } } else if (distToPlayer < 200.0f) { - nextAnimIndex = OOT_CHILD_EPONA_ANIM_GALLOP; + animIndex = OOT_CHILD_EPONA_ANIM_GALLOP; this->actor.speed = 6.0f; } else if (distToPlayer < 300.0f) { - nextAnimIndex = OOT_CHILD_EPONA_ANIM_TROT; + animIndex = OOT_CHILD_EPONA_ANIM_TROT; this->actor.speed = 4.0f; } else if (distToPlayer < 400.0f) { - nextAnimIndex = OOT_CHILD_EPONA_ANIM_WALK; + animIndex = OOT_CHILD_EPONA_ANIM_WALK; this->footstepCounter = 0; this->actor.speed = 2.0f; } else { this->actor.speed = 0.0f; if (this->animIndex == OOT_CHILD_EPONA_ANIM_IDLE) { - nextAnimIndex = (isAnimFinished == true) ? OOT_CHILD_EPONA_ANIM_WHINNY : OOT_CHILD_EPONA_ANIM_IDLE; + animIndex = (isAnimFinished == true) ? OOT_CHILD_EPONA_ANIM_WHINNY : OOT_CHILD_EPONA_ANIM_IDLE; } else { - nextAnimIndex = (isAnimFinished == true) ? OOT_CHILD_EPONA_ANIM_IDLE : OOT_CHILD_EPONA_ANIM_WHINNY; + animIndex = (isAnimFinished == true) ? OOT_CHILD_EPONA_ANIM_IDLE : OOT_CHILD_EPONA_ANIM_WHINNY; } } } else { this->actor.speed = 0.0f; if (this->animIndex == OOT_CHILD_EPONA_ANIM_IDLE) { - nextAnimIndex = (isAnimFinished == true) ? OOT_CHILD_EPONA_ANIM_WHINNY : OOT_CHILD_EPONA_ANIM_IDLE; + animIndex = (isAnimFinished == true) ? OOT_CHILD_EPONA_ANIM_WHINNY : OOT_CHILD_EPONA_ANIM_IDLE; } else { - nextAnimIndex = (isAnimFinished == true) ? OOT_CHILD_EPONA_ANIM_IDLE : OOT_CHILD_EPONA_ANIM_WHINNY; + animIndex = (isAnimFinished == true) ? OOT_CHILD_EPONA_ANIM_IDLE : OOT_CHILD_EPONA_ANIM_WHINNY; } } } - if ((nextAnimIndex != this->animIndex) || (isAnimFinished == true)) { - this->animIndex = nextAnimIndex; + if ((this->animIndex != animIndex) || (isAnimFinished == true)) { + this->animIndex = animIndex; Animation_Change(&this->skin.skelAnime, sAnimations[this->animIndex], EnHorseLinkChild_GetAnimSpeed(this), 0.0f, Animation_GetLastFrame(sAnimations[this->animIndex]), ANIMMODE_ONCE, -5.0f); } else { @@ -526,7 +524,7 @@ void EnHorseLinkChild_SetupActionFunc4(EnHorseLinkChild* this) { void EnHorseLinkChild_ActionFunc4(EnHorseLinkChild* this, PlayState* play) { Player* player = GET_PLAYER(play); f32 distToTargetPos; - s32 nextAnimIndex; + s32 animIndex; this->timer++; if (this->timer > 300) { @@ -551,24 +549,24 @@ void EnHorseLinkChild_ActionFunc4(EnHorseLinkChild* this, PlayState* play) { if (!this->isReturningHome) { if (distToTargetPos >= 300.0f) { - nextAnimIndex = OOT_CHILD_EPONA_ANIM_GALLOP; + animIndex = OOT_CHILD_EPONA_ANIM_GALLOP; this->actor.speed = 6.0f; } else if (distToTargetPos >= 150.0f) { - nextAnimIndex = OOT_CHILD_EPONA_ANIM_TROT; + animIndex = OOT_CHILD_EPONA_ANIM_TROT; this->actor.speed = 4.0f; } else { - nextAnimIndex = OOT_CHILD_EPONA_ANIM_WALK; + animIndex = OOT_CHILD_EPONA_ANIM_WALK; this->footstepCounter = 0; this->actor.speed = 2.0f; } } else if (distToTargetPos >= 300.0f) { - nextAnimIndex = OOT_CHILD_EPONA_ANIM_GALLOP; + animIndex = OOT_CHILD_EPONA_ANIM_GALLOP; this->actor.speed = 6.0f; } else if (distToTargetPos >= 150.0f) { - nextAnimIndex = OOT_CHILD_EPONA_ANIM_TROT; + animIndex = OOT_CHILD_EPONA_ANIM_TROT; this->actor.speed = 4.0f; } else if (distToTargetPos >= 70.0f) { - nextAnimIndex = OOT_CHILD_EPONA_ANIM_WALK; + animIndex = OOT_CHILD_EPONA_ANIM_WALK; this->footstepCounter = 0; this->actor.speed = 2.0f; } else { @@ -576,8 +574,8 @@ void EnHorseLinkChild_ActionFunc4(EnHorseLinkChild* this, PlayState* play) { return; } - if (nextAnimIndex != this->animIndex) { - this->animIndex = nextAnimIndex; + if (this->animIndex != animIndex) { + this->animIndex = animIndex; Animation_Change(&this->skin.skelAnime, sAnimations[this->animIndex], EnHorseLinkChild_GetAnimSpeed(this), 0.0f, Animation_GetLastFrame(sAnimations[this->animIndex]), ANIMMODE_ONCE, -5.0f); } else { diff --git a/src/overlays/actors/ovl_En_Hs/z_en_hs.c b/src/overlays/actors/ovl_En_Hs/z_en_hs.c index 5146f4fcd..b665b5d02 100644 --- a/src/overlays/actors/ovl_En_Hs/z_en_hs.c +++ b/src/overlays/actors/ovl_En_Hs/z_en_hs.c @@ -110,7 +110,7 @@ void EnHs_UpdateChickPos(Vec3f* dst, Vec3f src, f32 offset) { Math_Vec3f_Diff(&src, dst, &diff); - distance = SQ(diff.x) + SQ(diff.z); // gets un-squared after we check if we are too close + distance = SQXZ(diff); // gets un-squared after we check if we are too close if (SQ(offset) > distance) { return; @@ -176,20 +176,20 @@ void func_80953098(EnHs* this, PlayState* play) { void func_80953180(EnHs* this, PlayState* play) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { - case 0x33F4: // text: laughing that they are all roosters (!) - case 0x33F6: // text: Grog regrets not being able to see his chicks reach adult hood + case 0x33F4: // laughing that they are all roosters (!) + case 0x33F6: // Grog regrets not being able to see his chicks reach adult hood Message_CloseTextbox(play); this->actionFunc = func_8095345C; break; - case 0x33F7: // text: notice his chicks are grown up, happy, wants to give you bunny hood + case 0x33F7: // notice his chicks are grown up, happy, wants to give you bunny hood this->actor.flags &= ~ACTOR_FLAG_10000; Message_CloseTextbox(play); this->actionFunc = func_80953098; func_80953098(this, play); break; - case 0x33F9: // text: laughing that they are all roosters (.) + case 0x33F9: // laughing that they are all roosters (.) this->actor.flags &= ~ACTOR_FLAG_10000; Message_CloseTextbox(play); this->actionFunc = func_8095345C; @@ -341,6 +341,9 @@ s32 EnHs_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po return false; } break; + + default: + break; } return false; } diff --git a/src/overlays/actors/ovl_En_Jg/z_en_jg.c b/src/overlays/actors/ovl_En_Jg/z_en_jg.c index 7e30676e2..9fbd7ff85 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -417,11 +417,11 @@ void EnJg_GoronShrineCheer(EnJg* this, PlayState* play) { */ void EnJg_AlternateTalkOrWalkInPlace(EnJg* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); - s16 currentFrame = this->skelAnime.curFrame; + s16 curFrame = this->skelAnime.curFrame; s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); if (this->animIndex == EN_JG_ANIM_SURPRISE_START) { - if (currentFrame == lastFrame) { + if (curFrame == lastFrame) { this->animIndex = EN_JG_ANIM_SURPRISE_LOOP; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); } @@ -472,11 +472,11 @@ void EnJg_Walk(EnJg* this, PlayState* play) { void EnJg_Talk(EnJg* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); - s16 currentFrame = this->skelAnime.curFrame; + s16 curFrame = this->skelAnime.curFrame; s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); u16 temp; - if ((this->animIndex == EN_JG_ANIM_SURPRISE_START) && (currentFrame == lastFrame)) { + if ((this->animIndex == EN_JG_ANIM_SURPRISE_START) && (curFrame == lastFrame)) { this->animIndex = EN_JG_ANIM_SURPRISE_LOOP; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); } @@ -542,7 +542,7 @@ void EnJg_SetupWalk(EnJg* this, PlayState* play) { } void EnJg_Freeze(EnJg* this, PlayState* play) { - s16 currentFrame = this->skelAnime.curFrame; + s16 curFrame = this->skelAnime.curFrame; s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); if (this->action == EN_JG_ACTION_SPAWNING) { @@ -557,7 +557,7 @@ void EnJg_Freeze(EnJg* this, PlayState* play) { this->actionFunc = EnJg_FrozenIdle; } else if (this->animIndex == EN_JG_ANIM_FROZEN_START) { this->action = EN_JG_ACTION_FROZEN_OR_NON_FIRST_THAW; - if (currentFrame == lastFrame) { + if (curFrame == lastFrame) { this->freezeTimer = 1000; this->icePoly = Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_ICE_POLY, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, this->actor.world.rot.x, @@ -898,7 +898,7 @@ void EnJg_SpawnBreath(EnJg* this, PlayState* play) { * handing it off to EnJg_Freeze. */ void EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(EnJg* this, PlayState* play) { - s16 currentFrame = this->skelAnime.curFrame; + s16 curFrame = this->skelAnime.curFrame; s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { @@ -924,7 +924,7 @@ void EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(EnJg* this, PlayState* play } this->freezeTimer--; - if ((this->freezeTimer <= 0) && (currentFrame == lastFrame)) { + if ((this->freezeTimer <= 0) && (curFrame == lastFrame)) { this->animIndex = EN_JG_ANIM_FROZEN_START; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); Audio_PlaySfx_AtPos(&sSfxPos, NA_SE_EV_FREEZE_S); diff --git a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c index 73f1111a5..5ebdcd43f 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.c @@ -115,7 +115,7 @@ void EnPr2_Init(Actor* thisx, PlayState* play) { this->actor.colChkInfo.damageTable = &sDamageTable; SkelAnime_InitFlex(play, &this->skelAnime, &object_pr_Skel_004188, &object_pr_Anim_004340, this->jointTable, - this->morphtable, 5); + this->morphTable, 5); this->unk_1E0 = ENPR2_GET_F(&this->actor); this->actor.colChkInfo.mass = 10; Math_Vec3f_Copy(&this->unk_228, &this->actor.home.pos); diff --git a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h index 94fb7e033..7d462b639 100644 --- a/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h +++ b/src/overlays/actors/ovl_En_Pr2/z_en_pr2.h @@ -17,7 +17,7 @@ typedef struct EnPr2 { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ Vec3s jointTable[5]; - /* 0x1A6 */ Vec3s morphtable[5]; + /* 0x1A6 */ Vec3s morphTable[5]; /* 0x1C4 */ EnPr2ActionFunc actionFunc; /* 0x1C8 */ s16 pathIndex; /* 0x1CC */ Path* path; diff --git a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c index 605761711..c7006f087 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.c @@ -636,7 +636,7 @@ void EnSsh_Init(Actor* thisx, PlayState* play) { EnSsh* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_Init(play, &this->skelAnime, &object_ssh_Skel_006470, NULL, this->jointTable, this->morphtable, 30); + SkelAnime_Init(play, &this->skelAnime, &object_ssh_Skel_006470, NULL, this->jointTable, this->morphTable, 30); Animation_Change(&this->skelAnime, &object_ssh_Anim_001494, 1.0f, 0.0f, frameCount, ANIMMODE_LOOP_INTERP, 0.0f); this->blureIdx = EnSsh_CreateBlureEffect(play); EnSsh_InitColliders(this, play); diff --git a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.h b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.h index 6f19a5e51..8c95ea628 100644 --- a/src/overlays/actors/ovl_En_Ssh/z_en_ssh.h +++ b/src/overlays/actors/ovl_En_Ssh/z_en_ssh.h @@ -31,7 +31,7 @@ typedef struct EnSsh { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ Vec3s jointTable[30]; - /* 0x23C */ Vec3s morphtable[30]; + /* 0x23C */ Vec3s morphTable[30]; /* 0x2F0 */ EnSshActionFunc actionFunc; /* 0x2F4 */ ColliderCylinder collider1[6]; /* 0x4BC */ ColliderJntSph collider2; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 7ecc8c4e3..9a4244bc2 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -15951,7 +15951,7 @@ 0x80BDAF24:("ObjHsStump_Draw",), 0x80BDB040:("EnHiddenNuts_Init",), 0x80BDB188:("EnHiddenNuts_Destroy",), - 0x80BDB1B4:("func_80BDB1B4",), + 0x80BDB1B4:("EnHiddenNuts_ChangeAnim",), 0x80BDB268:("func_80BDB268",), 0x80BDB2B8:("func_80BDB2B8",), 0x80BDB580:("func_80BDB580",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 01a46d7d1..9320ca10e 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -15810,8 +15810,8 @@ 0x80BDAFA0:("D_80BDAFA0","f32","",0x4), 0x80BDC0B0:("En_Hidden_Nuts_InitVars","UNK_TYPE1","",0x1), 0x80BDC0D0:("D_80BDC0D0","UNK_TYPE1","",0x1), - 0x80BDC0FC:("D_80BDC0FC","UNK_TYPE1","",0x1), - 0x80BDC120:("D_80BDC120","UNK_TYPE1","",0x1), + 0x80BDC0FC:("sAnimations","UNK_TYPE1","",0x1), + 0x80BDC120:("sAnimationModes","UNK_TYPE1","",0x1), 0x80BDC12C:("D_80BDC12C","UNK_TYPE1","",0x1), 0x80BDC138:("D_80BDC138","UNK_TYPE1","",0x1), 0x80BDC144:("D_80BDC144","UNK_TYPE1","",0x1), From 9b1335aa7b5f33231e7bde444d77b38df3bfa87a Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Fri, 29 Sep 2023 23:14:05 +1000 Subject: [PATCH 6/9] Animation Cleanup: En_I* (#1400) * cleanup I * oops --- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 8 +- src/overlays/actors/ovl_En_Ig/z_en_ig.c | 168 ++++++++++------- src/overlays/actors/ovl_En_Ig/z_en_ig.h | 9 +- src/overlays/actors/ovl_En_Ik/z_en_ik.c | 8 +- src/overlays/actors/ovl_En_In/z_en_in.c | 174 ++++++++++-------- src/overlays/actors/ovl_En_In/z_en_in.h | 29 ++- .../actors/ovl_En_Insect/z_en_insect.c | 5 +- .../actors/ovl_En_Insect/z_en_insect.h | 5 +- .../z_en_invisible_ruppe.c | 3 + tools/disasm/functions.txt | 4 +- 10 files changed, 242 insertions(+), 171 deletions(-) diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index fe386b2ff..088e3fae0 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -2491,10 +2491,10 @@ void func_808819D8(EnHorse* this, PlayState* play) { } if (GET_WEEKEVENTREG_HORSE_RACE_STATE == WEEKEVENTREG_HORSE_RACE_STATE_3) { - this->rider->unk488 = 7; + this->rider->animIndex2 = ENIN_ANIM2_7; } else { EnHorse_SetIngoAnimation(this->animIndex, this->skin.skelAnime.curFrame, this->unk_394 & 1, - &this->rider->unk488); + &this->rider->animIndex2); } } @@ -3447,10 +3447,10 @@ void func_80884E0C(EnHorse* this, PlayState* play) { this->unk_56C = Math3D_Distance(&this->actor.world.pos, &this->actor.prevPos); if (((this->unk_550 == 5) || (this->unk_550 == 7)) && (Player_GetMask(play) != PLAYER_MASK_CIRCUS_LEADER)) { - this->rider->unk488 = 7; + this->rider->animIndex2 = ENIN_ANIM2_7; } else { EnHorse_SetIngoAnimation(this->animIndex, this->skin.skelAnime.curFrame, this->unk_394 & 1, - &this->rider->unk488); + &this->rider->animIndex2); } pos = this->actor.world.pos; diff --git a/src/overlays/actors/ovl_En_Ig/z_en_ig.c b/src/overlays/actors/ovl_En_Ig/z_en_ig.c index bd90f48c1..3006c7bfe 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -6,7 +6,6 @@ #include "z_en_ig.h" #include "overlays/actors/ovl_En_Door/z_en_door.h" -#include "objects/object_dai/object_dai.h" #define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_FRIENDLY | ACTOR_FLAG_10) @@ -143,17 +142,32 @@ static ColliderSphereInit sSphereInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static AnimationInfoS sAnimationInfo[] = { - { &object_dai_Anim_0048B4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dai_Anim_0048B4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dai_Anim_005100, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dai_Anim_005100, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dai_Anim_0010F8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dai_Anim_001E44, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_dai_Anim_0014BC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_dai_Anim_003CAC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, - { &object_dai_Anim_0040E0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_dai_Anim_0040E0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, +typedef enum EnIgAnimation { + /* -1 */ ENIG_ANIM_NONE = -1, + /* 0 */ ENIG_ANIM_0, + /* 1 */ ENIG_ANIM_1, + /* 2 */ ENIG_ANIM_2, + /* 3 */ ENIG_ANIM_3, + /* 4 */ ENIG_ANIM_4, + /* 5 */ ENIG_ANIM_5, + /* 6 */ ENIG_ANIM_6, + /* 7 */ ENIG_ANIM_7, + /* 8 */ ENIG_ANIM_8, + /* 9 */ ENIG_ANIM_9, + /* 10 */ ENIG_ANIM_MAX +} EnIgAnimation; + +static AnimationInfoS sAnimationInfo[ENIG_ANIM_MAX] = { + { &object_dai_Anim_0048B4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENIG_ANIM_0 + { &object_dai_Anim_0048B4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENIG_ANIM_1 + { &object_dai_Anim_005100, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENIG_ANIM_2 + { &object_dai_Anim_005100, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENIG_ANIM_3 + { &object_dai_Anim_0010F8, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, // ENIG_ANIM_4 + { &object_dai_Anim_001E44, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENIG_ANIM_5 + { &object_dai_Anim_0014BC, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, // ENIG_ANIM_6 + { &object_dai_Anim_003CAC, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, // ENIG_ANIM_7 + { &object_dai_Anim_0040E0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENIG_ANIM_8 + { &object_dai_Anim_0040E0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENIG_ANIM_9 }; Actor* func_80BF1150(EnIg* this, PlayState* play, u8 actorCat, s16 actorId) { @@ -204,44 +218,44 @@ EnDoor* func_80BF1200(PlayState* play, s32 arg1) { return SubS_FindDoor(play, phi_a1); } -void func_80BF1258(EnIg* this) { - this->skelAnime.playSpeed = this->unk_3D4; +void EnIg_UpdateSkelAnime(EnIg* this) { + this->skelAnime.playSpeed = this->animPlaySpeed; SkelAnime_Update(&this->skelAnime); } -s32 func_80BF1284(EnIg* this, s32 arg1) { - s32 phi_v1 = false; - s32 ret = false; +s32 EnIg_ChangeAnim(EnIg* this, s32 animIndex) { + s32 changeAnim = false; + s32 didAnimChange = false; - switch (arg1) { - case 0: - case 1: - if ((this->unk_3FC != 0) && (this->unk_3FC != 1)) { - phi_v1 = true; + switch (animIndex) { + case ENIG_ANIM_0: + case ENIG_ANIM_1: + if ((this->animIndex != ENIG_ANIM_0) && (this->animIndex != ENIG_ANIM_1)) { + changeAnim = true; } break; - case 2: - case 3: - if ((this->unk_3FC != 2) && (this->unk_3FC != 3)) { - phi_v1 = true; + case ENIG_ANIM_2: + case ENIG_ANIM_3: + if ((this->animIndex != ENIG_ANIM_2) && (this->animIndex != ENIG_ANIM_3)) { + changeAnim = true; } break; default: - if (arg1 != this->unk_3FC) { - phi_v1 = true; + if (this->animIndex != animIndex) { + changeAnim = true; } break; } - if (phi_v1) { - this->unk_3FC = arg1; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, arg1); - this->unk_3D4 = this->skelAnime.playSpeed; + if (changeAnim) { + this->animIndex = animIndex; + didAnimChange = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, animIndex); + this->animPlaySpeed = this->skelAnime.playSpeed; } - return ret; + return didAnimChange; } void func_80BF1354(EnIg* this, PlayState* play) { @@ -358,16 +372,18 @@ s32 func_80BF17BC(EnIg* this, PlayState* play) { switch (this->unk_3F6) { case 0: - if (func_80BF16C8(this, csId)) { - case 2: - case 4: - if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { - Camera_SetTargetActor(Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(csId)), - this->actor.child); - } - this->unk_3F6++; - ret = true; + if (!func_80BF16C8(this, csId)) { + break; } + // fallthrough + case 2: + case 4: + if ((this->actor.child != NULL) && (this->actor.child->update != NULL)) { + Camera_SetTargetActor(Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(csId)), + this->actor.child); + } + this->unk_3F6++; + ret = true; break; case 1: @@ -387,6 +403,9 @@ s32 func_80BF17BC(EnIg* this, PlayState* play) { this->unk_3F6++; ret = true; break; + + default: + break; } return ret; } @@ -438,10 +457,10 @@ s32 func_80BF19A0(EnIg* this, PlayState* play) { void func_80BF1A60(EnIg* this, PlayState* play) { if (this->unk_3F4 == 0) { - func_80BF1284(this, 4); + EnIg_ChangeAnim(this, ENIG_ANIM_4); this->unk_3F4++; } else if ((this->unk_3F4 == 1) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80BF1284(this, 5); + EnIg_ChangeAnim(this, ENIG_ANIM_5); this->unk_3F4++; } } @@ -449,7 +468,7 @@ void func_80BF1A60(EnIg* this, PlayState* play) { s32 func_80BF1AE0(EnIg* this, PlayState* play) { switch (this->scheduleResult) { case 3: - func_80BF1284(this, 0); + EnIg_ChangeAnim(this, ENIG_ANIM_0); break; case 10: @@ -457,7 +476,10 @@ s32 func_80BF1AE0(EnIg* this, PlayState* play) { case 12: case 13: case 14: - func_80BF1284(this, 2); + EnIg_ChangeAnim(this, ENIG_ANIM_2); + break; + + default: break; } return true; @@ -471,8 +493,8 @@ s32 func_80BF1B40(EnIg* this, PlayState* play) { if (player->stateFlags1 & (PLAYER_STATE1_40 | PLAYER_STATE1_400 | PLAYER_STATE1_800)) { this->unk_3D0 |= 0x400; if (this->unk_3D2 != temp) { - if ((this->unk_3FC == 2) || (this->unk_3FC == 3)) { - func_80BF1284(this, 0); + if ((this->animIndex == ENIG_ANIM_2) || (this->animIndex == ENIG_ANIM_3)) { + EnIg_ChangeAnim(this, ENIG_ANIM_0); } if ((temp == 0x28B0) || (temp == 0x28B7)) { @@ -484,7 +506,10 @@ s32 func_80BF1B40(EnIg* this, PlayState* play) { } else if (this->unk_3D0 & 0x400) { this->unk_3D2 = 0; this->unk_3D0 &= ~0x400; + + //! FAKE: if (1) {} + func_80BF1AE0(this, play); } @@ -529,7 +554,7 @@ s32 func_80BF1D78(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput) { s32 sp2C = 0; if (func_80BF1C44(this, play, scheduleOutput, ACTORCAT_NPC, ACTOR_EN_AN)) { - func_80BF1284(this, 0); + EnIg_ChangeAnim(this, ENIG_ANIM_0); SubS_SetOfferMode(&this->unk_3D0, SUBS_OFFER_MODE_ONSCREEN, SUBS_OFFER_MODE_MASK); this->unk_3D0 |= 0x20; this->unk_3D0 |= 0x100; @@ -575,7 +600,7 @@ s32 func_80BF1DF4(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput) { this->unk_3E2 = sp56 - scheduleOutput->time0; this->actor.flags &= ~ACTOR_FLAG_TARGETABLE; this->unk_3D0 |= 0x100; - func_80BF1284(this, 3); + EnIg_ChangeAnim(this, ENIG_ANIM_3); this->actor.gravity = 0.0f; ret = true; } @@ -626,7 +651,7 @@ s32 func_80BF1FA8(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput) { this->unk_3D0 &= ~0x10; SubS_SetOfferMode(&this->unk_3D0, SUBS_OFFER_MODE_ONSCREEN, SUBS_OFFER_MODE_MASK); this->unk_3D0 |= 0x100; - func_80BF1284(this, 2); + EnIg_ChangeAnim(this, ENIG_ANIM_2); this->actor.gravity = -1.0f; ret = true; } @@ -662,7 +687,7 @@ s32 func_80BF219C(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput) { this->actor.home.rot.y += 0x8000; SubS_SetOfferMode(&this->unk_3D0, SUBS_OFFER_MODE_ONSCREEN, SUBS_OFFER_MODE_MASK); this->unk_3D0 |= 0x100; - func_80BF1284(this, 1); + EnIg_ChangeAnim(this, ENIG_ANIM_1); break; case 4: @@ -670,7 +695,10 @@ s32 func_80BF219C(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput) { this->actor.shape.rot.y = this->actor.world.rot.y; SubS_SetOfferMode(&this->unk_3D0, SUBS_OFFER_MODE_ONSCREEN, SUBS_OFFER_MODE_MASK); this->unk_3D0 |= 0x100; - func_80BF1284(this, 8); + EnIg_ChangeAnim(this, ENIG_ANIM_8); + break; + + default: break; } ret = true; @@ -710,6 +738,9 @@ s32 func_80BF2368(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput) { case 3: ret = func_80BF1D78(this, play, scheduleOutput); break; + + default: + break; } return ret; } @@ -765,6 +796,7 @@ s32 func_80BF25E8(EnIg* this, PlayState* play) { s32 pad; SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); + if (!(this->unk_3D0 & 8)) { timePathTargetPos = gZeroVec3f; SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, @@ -830,11 +862,11 @@ s32 func_80BF293C(EnIg* this, PlayState* play) { Math_ApproachS(&this->actor.world.rot.y, this->actor.home.rot.y, 3, 0x2AA8); } else { this->actor.world.rot.y = this->actor.home.rot.y; - func_80BF1284(this, 7); + EnIg_ChangeAnim(this, ENIG_ANIM_7); } - } else if ((this->unk_3FC == 7) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + } else if ((this->animIndex == ENIG_ANIM_7) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { SubS_SetOfferMode(&this->unk_3D0, SUBS_OFFER_MODE_ONSCREEN, SUBS_OFFER_MODE_MASK); - func_80BF1284(this, 9); + EnIg_ChangeAnim(this, ENIG_ANIM_9); } return true; } @@ -868,6 +900,9 @@ void func_80BF2A50(EnIg* this, PlayState* play) { case 4: func_80BF2890(this, play); break; + + default: + break; } Math_ApproachS(&this->actor.shape.rot.y, this->actor.world.rot.y, 3, 0x2AA8); } @@ -916,9 +951,10 @@ void EnIg_Init(Actor* thisx, PlayState* play) { EnIg* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 28.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &object_dai_Skel_0130D0, NULL, this->jointTable, this->morphTable, 19); - this->unk_3FC = -1; - func_80BF1284(this, 0); + SkelAnime_InitFlex(play, &this->skelAnime, &object_dai_Skel_0130D0, NULL, this->jointTable, this->morphTable, + OBJECT_DAI_LIMB_MAX); + this->animIndex = ENIG_ANIM_NONE; + EnIg_ChangeAnim(this, ENIG_ANIM_0); Collider_InitAndSetCylinder(play, &this->collider1, &this->actor, &sCylinderInit); Collider_InitAndSetSphere(play, &this->collider2, &this->actor, &sSphereInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); @@ -946,7 +982,7 @@ void EnIg_Update(Actor* thisx, PlayState* play) { func_80BF1B40(this, play); if (this->scheduleResult != 0) { - func_80BF1258(this); + EnIg_UpdateSkelAnime(this); func_80BF13E4(this); func_80BF15EC(this); SubS_Offer(&this->actor, play, 60.0f, 30.0f, PLAYER_IA_NONE, this->unk_3D0 & SUBS_OFFER_MODE_MASK); @@ -960,7 +996,7 @@ s32 EnIg_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po Gfx** gfx) { EnIg* this = THIS; - if (limbIndex == 10) { + if (limbIndex == OBJECT_DAI_LIMB_0A) { *dList = NULL; } return false; @@ -973,7 +1009,7 @@ void EnIg_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, EnIg* this = THIS; Vec3f sp2C; - if (limbIndex == 11) { + if (limbIndex == OBJECT_DAI_LIMB_0B) { Matrix_MultVec3f(&D_80BF3528, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); @@ -981,17 +1017,17 @@ void EnIg_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, gSPDisplayList((*gfx)++, object_dai_DL_0087B8); } - if (limbIndex == 12) { + if (limbIndex == OBJECT_DAI_LIMB_0C) { gSPDisplayList((*gfx)++, object_dai_DL_0089D8); } - if (limbIndex == 9) { + if (limbIndex == OBJECT_DAI_LIMB_09) { gSPDisplayList((*gfx)++, object_dai_DL_008B00); Matrix_MultVec3f(&D_80BF351C, &sp2C); Math_Vec3f_ToVec3s(&this->collider2.dim.worldSphere.center, &sp2C); } - if (limbIndex == 10) { + if (limbIndex == OBJECT_DAI_LIMB_0A) { Matrix_Get(&this->unk_190); } } @@ -1013,7 +1049,7 @@ void EnIg_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx, Gfx** stepRot = false; } - if (limbIndex == 9) { + if (limbIndex == OBJECT_DAI_LIMB_09) { SubS_UpdateLimb(this->unk_3E8 + 0x4000, this->unk_3EA + this->actor.shape.rot.y + 0x4000, &this->unk_2D4, &this->unk_2E6, stepRot, overrideRot); Matrix_Pop(); diff --git a/src/overlays/actors/ovl_En_Ig/z_en_ig.h b/src/overlays/actors/ovl_En_Ig/z_en_ig.h index 274338a11..71c7c509d 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.h +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.h @@ -2,6 +2,7 @@ #define Z_EN_IG_H #include "global.h" +#include "objects/object_dai/object_dai.h" struct EnIg; @@ -38,11 +39,11 @@ typedef struct EnIg { /* 0x2D4 */ Vec3f unk_2D4; /* 0x2E0 */ UNK_TYPE1 unk2E0[0x6]; /* 0x2E6 */ Vec3s unk_2E6; - /* 0x2EC */ Vec3s jointTable[19]; - /* 0x35E */ Vec3s morphTable[19]; + /* 0x2EC */ Vec3s jointTable[OBJECT_DAI_LIMB_MAX]; + /* 0x35E */ Vec3s morphTable[OBJECT_DAI_LIMB_MAX]; /* 0x3D0 */ u16 unk_3D0; /* 0x3D2 */ u16 unk_3D2; - /* 0x3D4 */ f32 unk_3D4; + /* 0x3D4 */ f32 animPlaySpeed; /* 0x3D8 */ UNK_TYPE1 unk3D8[0x8]; /* 0x3E0 */ s16 unk_3E0; /* 0x3E2 */ s16 unk_3E2; @@ -57,7 +58,7 @@ typedef struct EnIg { /* 0x3F4 */ s16 unk_3F4; /* 0x3F6 */ s16 unk_3F6; /* 0x3F8 */ EnIgUnkFunc unk_3F8; - /* 0x3FC */ s32 unk_3FC; + /* 0x3FC */ s32 animIndex; /* 0x400 */ UNK_TYPE1 unk400[0x8]; /* 0x408 */ s32 unk_408; } EnIg; // size = 0x40C diff --git a/src/overlays/actors/ovl_En_Ik/z_en_ik.c b/src/overlays/actors/ovl_En_Ik/z_en_ik.c index 96ce3db8c..7f3ed6de4 100644 --- a/src/overlays/actors/ovl_En_Ik/z_en_ik.c +++ b/src/overlays/actors/ovl_En_Ik/z_en_ik.c @@ -365,15 +365,15 @@ void EnIk_CheckActions(EnIk* this, PlayState* play) { } void EnIk_SetupIdle(EnIk* this) { - f32 frameCount = Animation_GetLastFrame(&gIronKnuckleHorizontalAttackAnim); + f32 endFrame = Animation_GetLastFrame(&gIronKnuckleHorizontalAttackAnim); if (this->drawArmorFlags != 0) { this->timer = 10; } else { this->timer = 0; } - Animation_Change(&this->skelAnime, &gIronKnuckleEndHorizontalAttackAnim, 1.0f, frameCount, frameCount, - ANIMMODE_ONCE, this->timer); + Animation_Change(&this->skelAnime, &gIronKnuckleEndHorizontalAttackAnim, 1.0f, endFrame, endFrame, ANIMMODE_ONCE, + this->timer); this->actionFunc = EnIk_Idle; this->actor.speed = 0.0f; } @@ -461,7 +461,7 @@ void EnIk_SetupVerticalAttack(EnIk* this) { playbackSpeed = 1.2f; } Animation_Change(&this->skelAnime, &gIronKnuckleVerticalAttackAnim, playbackSpeed, 0.0f, - Animation_GetLastFrame(&gIronKnuckleVerticalAttackAnim.common), 3, -4.0f); + Animation_GetLastFrame(&gIronKnuckleVerticalAttackAnim.common), ANIMMODE_ONCE_INTERP, -4.0f); this->timer = 0; this->blurEffectSpawnLock = -1; this->actionFunc = EnIk_VerticalAttack; diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index 1c0fc091d..19fbd436e 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -118,25 +118,25 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static AnimationInfoS sAnimationInfo[] = { - { &object_in_Anim_001D10, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_in_Anim_001D10, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_in_Anim_014F8C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_in_Anim_014F8C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_in_Anim_000CB0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_in_Anim_0003B4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_in_Anim_001BE0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_in_Anim_015918, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_in_Anim_01C0B0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_in_Anim_01C0B0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_in_Anim_01A140, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_in_Anim_01A140, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_in_Anim_01B904, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_in_Anim_01B904, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_in_Anim_01B3C4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &object_in_Anim_01B3C4, 0.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &object_in_Anim_01B3C4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, - { &object_in_Anim_019EB4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, +static AnimationInfoS sAnimationInfo[ENIN_ANIM_MAX] = { + { &object_in_Anim_001D10, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENIN_ANIM_0 + { &object_in_Anim_001D10, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENIN_ANIM_1 + { &object_in_Anim_014F8C, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENIN_ANIM_2 + { &object_in_Anim_014F8C, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENIN_ANIM_3 + { &object_in_Anim_000CB0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENIN_ANIM_4 + { &object_in_Anim_0003B4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENIN_ANIM_5 + { &object_in_Anim_001BE0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENIN_ANIM_6 + { &object_in_Anim_015918, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENIN_ANIM_7 + { &object_in_Anim_01C0B0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENIN_ANIM_8 + { &object_in_Anim_01C0B0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENIN_ANIM_9 + { &object_in_Anim_01A140, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENIN_ANIM_10 + { &object_in_Anim_01A140, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENIN_ANIM_11 + { &object_in_Anim_01B904, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENIN_ANIM_12 + { &object_in_Anim_01B904, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENIN_ANIM_13 + { &object_in_Anim_01B3C4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENIN_ANIM_14 + { &object_in_Anim_01B3C4, 0.0f, 0, -1, ANIMMODE_ONCE, 0 }, // ENIN_ANIM_15 + { &object_in_Anim_01B3C4, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENIN_ANIM_16 + { &object_in_Anim_019EB4, 1.0f, 0, -1, ANIMMODE_ONCE, -4 }, // ENIN_ANIM_17 }; static TrackOptionsSet sTrackOptions = { @@ -147,20 +147,20 @@ static TrackOptionsSet sTrackOptions = { }; s32 EnIn_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) { - s16 frameCount; - s32 ret = false; + s16 endFrame; + s32 didAnimChange = false; - if ((animIndex >= 0) && (animIndex < 18)) { - ret = true; - frameCount = sAnimationInfo[animIndex].frameCount; - if (frameCount < 0) { - frameCount = Animation_GetLastFrame(sAnimationInfo[animIndex].animation); + if ((animIndex > ENIN_ANIM_NONE) && (animIndex < ENIN_ANIM_MAX)) { + didAnimChange = true; + endFrame = sAnimationInfo[animIndex].frameCount; + if (endFrame < 0) { + endFrame = Animation_GetLastFrame(sAnimationInfo[animIndex].animation); } Animation_Change(skelAnime, sAnimationInfo[animIndex].animation, sAnimationInfo[animIndex].playSpeed, - sAnimationInfo[animIndex].startFrame, frameCount, sAnimationInfo[animIndex].mode, + sAnimationInfo[animIndex].startFrame, endFrame, sAnimationInfo[animIndex].mode, sAnimationInfo[animIndex].morphFrames); } - return ret; + return didAnimChange; } s32 func_808F3178(EnIn* this, PlayState* play) { @@ -298,12 +298,19 @@ void func_808F3690(EnIn* this, PlayState* play) { } void func_808F374C(EnIn* this, PlayState* play) { - AnimationHeader* sAnimations[] = { - &object_in_Anim_015E38, &object_in_Anim_016A60, &object_in_Anim_0177AC, &object_in_Anim_016484, - &object_in_Anim_0170DC, &object_in_Anim_018240, &object_in_Anim_0187C8, &object_in_Anim_0198A8, + AnimationHeader* sAnimations[ENIN_ANIM2_MAX] = { + &object_in_Anim_015E38, // ENIN_ANIM2_0 + &object_in_Anim_016A60, // ENIN_ANIM2_1 + &object_in_Anim_0177AC, // ENIN_ANIM2_2 + &object_in_Anim_016484, // ENIN_ANIM2_3 + &object_in_Anim_0170DC, // ENIN_ANIM2_4 + &object_in_Anim_018240, // ENIN_ANIM2_5 + &object_in_Anim_0187C8, // ENIN_ANIM2_6 + &object_in_Anim_0198A8, // ENIN_ANIM2_7 }; - if (this->skelAnime.animation == &object_in_Anim_016484 || this->skelAnime.animation == &object_in_Anim_0170DC) { + if ((this->skelAnime.animation == &object_in_Anim_016484) || + (this->skelAnime.animation == &object_in_Anim_0170DC)) { if (Animation_OnFrame(&this->skelAnime, 8.0f)) { Audio_PlaySfx_Randomized(&this->actor.projectedPos, NA_SE_VO_IN_LASH_0, 2); if (Rand_ZeroOne() < 0.3f) { @@ -312,14 +319,16 @@ void func_808F374C(EnIn* this, PlayState* play) { Audio_PlaySfx_AtPos(&this->actor.projectedPos, NA_SE_IT_LASH); } } - if (this->skelAnime.animation == &object_in_Anim_0198A8 && Animation_OnFrame(&this->skelAnime, 20.0f)) { + + if ((this->skelAnime.animation == &object_in_Anim_0198A8) && Animation_OnFrame(&this->skelAnime, 20.0f)) { Actor_PlaySfx(&this->actor, NA_SE_VO_IN_CRY_0); } + if (SkelAnime_Update(&this->skelAnime)) { - this->unk488 %= ARRAY_COUNT(sAnimations); - this->unk486 = this->unk488; - Animation_Change(&this->skelAnime, sAnimations[this->unk488], 1.0f, 0.0f, - Animation_GetLastFrame(sAnimations[this->unk488]), ANIMMODE_ONCE, -10.0f); + this->animIndex2 %= ENIN_ANIM2_MAX; + this->unk486 = this->animIndex2; + Animation_Change(&this->skelAnime, sAnimations[this->animIndex2], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimations[this->animIndex2]), ANIMMODE_ONCE, -10.0f); } } @@ -407,7 +416,7 @@ void func_808F3B40(EnIn* this, PlayState* play) { this->actor.parent = NULL; this->actor.flags |= ACTOR_FLAG_10000; this->actionFunc = func_808F3AD4; - textId = gSaveContext.save.day != 3 ? 0x3481 : 0x34A4; + textId = (gSaveContext.save.day != 3) ? 0x3481 : 0x34A4; this->actor.textId = textId; } else { Actor_OfferGetItem(&this->actor, play, GI_MILK, 500.0f, 100.0f); @@ -958,6 +967,7 @@ s32 func_808F4414(PlayState* play, EnIn* this, s32 arg2) { ret = false; } break; + case 0x347E: func_808F35D8(this, play); if (Inventory_HasEmptyBottle()) { @@ -1430,7 +1440,7 @@ void func_808F5A94(EnIn* this, PlayState* play) { void func_808F5B58(EnIn* this, PlayState* play) { if (Horse_IsActive(play, &play->actorCtx)) { - if ((Player_GetMask(play) == PLAYER_MASK_CIRCUS_LEADER && CHECK_WEEKEVENTREG(WEEKEVENTREG_63_40)) || + if (((Player_GetMask(play) == PLAYER_MASK_CIRCUS_LEADER) && CHECK_WEEKEVENTREG(WEEKEVENTREG_63_40)) || CHECK_WEEKEVENTREG(WEEKEVENTREG_56_08)) { if (gSaveContext.save.day == 3) { func_808F5728(play, this, 6, &this->unk48C); @@ -1438,8 +1448,8 @@ void func_808F5B58(EnIn* this, PlayState* play) { func_808F5728(play, this, 2, &this->unk48C); } } - } else if (Player_GetMask(play) != PLAYER_MASK_CIRCUS_LEADER || - (Player_GetMask(play) == PLAYER_MASK_CIRCUS_LEADER && CHECK_WEEKEVENTREG(WEEKEVENTREG_63_40))) { + } else if ((Player_GetMask(play) != PLAYER_MASK_CIRCUS_LEADER) || + ((Player_GetMask(play) == PLAYER_MASK_CIRCUS_LEADER) && CHECK_WEEKEVENTREG(WEEKEVENTREG_63_40))) { if (gSaveContext.save.day == 3) { func_808F5728(play, this, 4, &this->unk48C); } else { @@ -1452,7 +1462,7 @@ void func_808F5C98(EnIn* this, PlayState* play) { if (this->unk4B0 == WEEKEVENTREG_HORSE_RACE_STATE_END) { this->actionFunc = func_808F5B58; } - if ((Player_GetMask(play) == PLAYER_MASK_CIRCUS_LEADER && CHECK_WEEKEVENTREG(WEEKEVENTREG_63_40)) || + if (((Player_GetMask(play) == PLAYER_MASK_CIRCUS_LEADER) && CHECK_WEEKEVENTREG(WEEKEVENTREG_63_40)) || CHECK_WEEKEVENTREG(WEEKEVENTREG_56_08)) { if (gSaveContext.save.day != 3) { func_808F5728(play, this, 2, &this->unk48C); @@ -1484,7 +1494,8 @@ void EnIn_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &object_in_Skel_014EA8, NULL, this->jointTable, this->morphTable, 20); + SkelAnime_InitFlex(play, &this->skelAnime, &object_in_Skel_014EA8, NULL, this->jointTable, this->morphTable, + OBJECT_IN_LIMB_MAX); EnIn_ChangeAnim(&this->skelAnime, ENIN_ANIM_0); Collider_InitCylinder(play, &this->colliderCylinder); Collider_SetCylinder(play, &this->colliderCylinder, &this->actor, &sCylinderInit); @@ -1499,7 +1510,7 @@ void EnIn_Init(Actor* thisx, PlayState* play) { } if ((type == ENIN_HORSE_RIDER_YELLOW_SHIRT) || (type == ENIN_HORSE_RIDER_BLUE_SHIRT)) { ActorShape_Init(&this->actor.shape, 0.0f, NULL, 0.0f); - this->unk488 = 1; + this->animIndex2 = ENIN_ANIM2_1; Animation_Change(&this->skelAnime, &object_in_Anim_016A60, 1.0f, 0.0f, Animation_GetLastFrame(&object_in_Anim_016A60), ANIMMODE_ONCE, 0.0f); Actor_SetScale(&this->actor, 0.01f); @@ -1623,41 +1634,41 @@ void func_808F6334(EnIn* this, PlayState* play) { s32 EnIn_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnIn* this = THIS; s32 pad; - Gfx* sp50[] = { - NULL, - NULL, - object_in_DL_0149A8, - object_in_DL_014AE0, - object_in_DL_014C30, - object_in_DL_0145D8, - object_in_DL_014710, - object_in_DL_014860, - object_in_DL_014420, - object_in_DL_012A78, - object_in_DL_013DE0, - object_in_DL_013F10, - object_in_DL_014040, - object_in_DL_0137A0, - object_in_DL_0138D0, - object_in_DL_013A00, - object_in_DL_012DF8, - object_in_DL_013670, - object_in_DL_013540, - object_in_DL_013440, + Gfx* sp50[OBJECT_IN_LIMB_MAX] = { + NULL, // OBJECT_IN_LIMB_NONE + NULL, // OBJECT_IN_LIMB_01 + object_in_DL_0149A8, // OBJECT_IN_LIMB_02 + object_in_DL_014AE0, // OBJECT_IN_LIMB_03 + object_in_DL_014C30, // OBJECT_IN_LIMB_04 + object_in_DL_0145D8, // OBJECT_IN_LIMB_05 + object_in_DL_014710, // OBJECT_IN_LIMB_06 + object_in_DL_014860, // OBJECT_IN_LIMB_07 + object_in_DL_014420, // OBJECT_IN_LIMB_08 + object_in_DL_012A78, // OBJECT_IN_LIMB_09 + object_in_DL_013DE0, // OBJECT_IN_LIMB_0A + object_in_DL_013F10, // OBJECT_IN_LIMB_0B + object_in_DL_014040, // OBJECT_IN_LIMB_0C + object_in_DL_0137A0, // OBJECT_IN_LIMB_0D + object_in_DL_0138D0, // OBJECT_IN_LIMB_0E + object_in_DL_013A00, // OBJECT_IN_LIMB_0F + object_in_DL_012DF8, // OBJECT_IN_LIMB_10 + object_in_DL_013670, // OBJECT_IN_LIMB_11 + object_in_DL_013540, // OBJECT_IN_LIMB_12 + object_in_DL_013440, // OBJECT_IN_LIMB_13 }; - if ((this->unk23C != 0) && (limbIndex != 16)) { + if ((this->unk23C != 0) && (limbIndex != OBJECT_IN_LIMB_10)) { if (sp50[limbIndex] != NULL) { *dList = sp50[limbIndex]; } } - if ((this->unk4AC & 4) && (limbIndex == 16)) { + if ((this->unk4AC & 4) && (limbIndex == OBJECT_IN_LIMB_10)) { *dList = object_in_DL_01C528; } OPEN_DISPS(play->state.gfxCtx); - if (limbIndex == 16) { + if (limbIndex == OBJECT_IN_LIMB_10) { TexturePtr sp38[] = { object_in_Tex_0035E0, object_in_Tex_004820, object_in_Tex_004C20, object_in_Tex_0043E0 }; gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp38[this->unk482])); @@ -1668,31 +1679,34 @@ s32 EnIn_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po CLOSE_DISPS(play->state.gfxCtx); - if (limbIndex == 16) { + if (limbIndex == OBJECT_IN_LIMB_10) { Matrix_Translate(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); Matrix_RotateZS(-this->headRot.x, MTXMODE_APPLY); Matrix_Translate(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); func_808F6334(this, play); } - if (limbIndex == 9) { + + if (limbIndex == OBJECT_IN_LIMB_09) { Matrix_RotateYS(this->torsoRot.y, MTXMODE_APPLY); Matrix_RotateXS(this->torsoRot.x, MTXMODE_APPLY); } - if ((limbIndex == 9) || (limbIndex == 10) || (limbIndex == 13)) { + + if ((limbIndex == OBJECT_IN_LIMB_09) || (limbIndex == OBJECT_IN_LIMB_0A) || (limbIndex == OBJECT_IN_LIMB_0D)) { rot->y += (s16)(Math_SinS(this->fidgetTableY[limbIndex]) * 200.0f); rot->z += (s16)(Math_CosS(this->fidgetTableZ[limbIndex]) * 200.0f); } + if (this->unk4AC & 0x40) { - if (limbIndex == 18) { + if (limbIndex == OBJECT_IN_LIMB_12) { rot->x = 0x1F40; rot->y = -0x3E8; rot->z = 0x1D4C; - } else if (limbIndex == 17) { + } else if (limbIndex == OBJECT_IN_LIMB_11) { rot->x = -0x1F40; rot->y = 0x3E8; rot->z = 0x1D4C; - } else if (limbIndex == 19) { + } else if (limbIndex == OBJECT_IN_LIMB_13) { rot->x = 0; rot->y = 0x7FFF; rot->z = -0x2328; @@ -1706,26 +1720,26 @@ void EnIn_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Vec3f sp50 = { 1600.0f, 0.0f, 0.0f }; Vec3f sp44 = { 0.0f, 0.0f, 0.0f }; - if (limbIndex == 16) { + if (limbIndex == OBJECT_IN_LIMB_10) { Matrix_MultVec3f(&sp50, &this->unk4B4); Math_Vec3f_Copy(&this->actor.focus.pos, &this->unk4B4); } if (this->unk23D == 0) { Collider_UpdateSpheres(limbIndex, &this->colliderJntSph); - if (limbIndex == 4) { + if (limbIndex == OBJECT_IN_LIMB_04) { Matrix_MultVec3f(&sp44, &this->unk248); } - if (limbIndex == 7) { + if (limbIndex == OBJECT_IN_LIMB_07) { Matrix_MultVec3f(&sp44, &this->unk254); } if (this->unk23C == 0) { if (!(this->unk4AC & 8)) { OPEN_DISPS(play->state.gfxCtx); - if (limbIndex == 12) { + if (limbIndex == OBJECT_IN_LIMB_0C) { gSPDisplayList(POLY_OPA_DISP++, object_in_DL_007A70); } - if (limbIndex == 15) { + if (limbIndex == OBJECT_IN_LIMB_0F) { gSPDisplayList(POLY_OPA_DISP++, object_in_DL_007C48); } @@ -1736,7 +1750,7 @@ void EnIn_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, if (this->unk4AC & 0x20) { OPEN_DISPS(play->state.gfxCtx); - if (limbIndex == 12) { + if (limbIndex == OBJECT_IN_LIMB_0C) { gSPDisplayList(POLY_OPA_DISP++, object_in_DL_007C48); } diff --git a/src/overlays/actors/ovl_En_In/z_en_in.h b/src/overlays/actors/ovl_En_In/z_en_in.h index c4833568c..ab774606a 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.h +++ b/src/overlays/actors/ovl_En_In/z_en_in.h @@ -16,7 +16,13 @@ typedef enum { /* 4 */ ENIN_BLUE_SHIRT } EnInType; -typedef enum { +#define ENIN_GET_TYPE(thisx) ((thisx)->params & 0x1FF) +#define ENIN_GET_PATH_INDEX(thisx) (((thisx)->params & 0x7E00) >> 9) // Only used with ENIN_UNK_TYPE + +#define ENIN_PATH_INDEX_NONE 0x3F + +typedef enum EnInAnimation { + /* -1 */ ENIN_ANIM_NONE = -1, /* 0 */ ENIN_ANIM_0, /* 1 */ ENIN_ANIM_1, /* 2 */ ENIN_ANIM_2, @@ -34,13 +40,22 @@ typedef enum { /* 14 */ ENIN_ANIM_14, /* 15 */ ENIN_ANIM_15, /* 16 */ ENIN_ANIM_16, - /* 17 */ ENIN_ANIM_17 + /* 17 */ ENIN_ANIM_17, + /* 18 */ ENIN_ANIM_MAX } EnInAnimation; -#define ENIN_GET_TYPE(thisx) ((thisx)->params & 0x1FF) -#define ENIN_GET_PATH_INDEX(thisx) (((thisx)->params & 0x7E00) >> 9) // Only used with ENIN_UNK_TYPE - -#define ENIN_PATH_INDEX_NONE 0x3F +typedef enum EnInAnimation2 { + /* -1 */ ENIN_ANIM2_NONE = -1, + /* 0 */ ENIN_ANIM2_0, + /* 1 */ ENIN_ANIM2_1, + /* 2 */ ENIN_ANIM2_2, + /* 3 */ ENIN_ANIM2_3, + /* 4 */ ENIN_ANIM2_4, + /* 5 */ ENIN_ANIM2_5, + /* 6 */ ENIN_ANIM2_6, + /* 7 */ ENIN_ANIM2_7, + /* 8 */ ENIN_ANIM2_MAX +} EnInAnimation2; typedef struct EnIn { /* 0x000 */ Actor actor; @@ -70,7 +85,7 @@ typedef struct EnIn { /* 0x482 */ s16 unk482; /* 0x484 */ s16 unk484; /* 0x486 */ s16 unk486; - /* 0x488 */ s16 unk488; + /* 0x488 */ s16 animIndex2; /* 0x48A */ u16 unk48A; /* 0x48C */ s32 unk48C; /* 0x490 */ UNK_TYPE1 unk490[0x4]; diff --git a/src/overlays/actors/ovl_En_Insect/z_en_insect.c b/src/overlays/actors/ovl_En_Insect/z_en_insect.c index 6a51e9486..9d8667f0a 100644 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.c +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.c @@ -5,7 +5,6 @@ */ #include "z_en_insect.h" -#include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS 0x00000000 @@ -132,7 +131,7 @@ void EnInsect_Init(Actor* thisx, PlayState* play) { func_8091A8A0(this); SkelAnime_Init(play, &this->skelAnime, &gameplay_keep_Skel_0527A0, &gameplay_keep_Anim_05140C, this->jointTable, - this->morphTable, 24); + this->morphTable, BUG_LIMB_MAX); Animation_Change(&this->skelAnime, &gameplay_keep_Anim_05140C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP_INTERP, 0.0f); Collider_InitJntSph(play, &this->collider); Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); @@ -278,7 +277,9 @@ void func_8091B07C(EnInsect* this, PlayState* play) { yaw -= 0x2000; } + //! FAKE: if (play) {} + Math_ScaledStepToS(&this->actor.world.rot.y, yaw, 0x7D0); } diff --git a/src/overlays/actors/ovl_En_Insect/z_en_insect.h b/src/overlays/actors/ovl_En_Insect/z_en_insect.h index 4e1f5b762..4fd2985f1 100644 --- a/src/overlays/actors/ovl_En_Insect/z_en_insect.h +++ b/src/overlays/actors/ovl_En_Insect/z_en_insect.h @@ -2,6 +2,7 @@ #define Z_EN_INSECT_H #include "global.h" +#include "objects/gameplay_keep/gameplay_keep.h" struct EnInsect; @@ -16,8 +17,8 @@ typedef struct EnInsect { /* 0x144 */ ColliderJntSph collider; /* 0x164 */ ColliderJntSphElement colliderElements[1]; /* 0x1A4 */ SkelAnime skelAnime; - /* 0x1E8 */ Vec3s jointTable[24]; - /* 0x278 */ Vec3s morphTable[24]; + /* 0x1E8 */ Vec3s jointTable[BUG_LIMB_MAX]; + /* 0x278 */ Vec3s morphTable[BUG_LIMB_MAX]; /* 0x308 */ EnInsectActionFunc actionFunc; /* 0x30C */ u16 unk_30C; /* 0x30E */ s16 unk_30E; diff --git a/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c b/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c index ef64e3954..3a6c54983 100644 --- a/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c +++ b/src/overlays/actors/ovl_En_Invisible_Ruppe/z_en_invisible_ruppe.c @@ -75,6 +75,9 @@ void func_80C2590C(EnInvisibleRuppe* this, PlayState* play) { Audio_PlaySfx(NA_SE_SY_GET_RUPY); Item_DropCollectible(play, &this->actor.world.pos, 0x8000 | ITEM00_RUPEE_RED); break; + + default: + break; } if (this->unk_190 >= 0) { diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 9a4244bc2..0ecbdb9b1 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -16283,8 +16283,8 @@ 0x80BF0F10:("EffStk_Draw",), 0x80BF1150:("func_80BF1150",), 0x80BF1200:("func_80BF1200",), - 0x80BF1258:("func_80BF1258",), - 0x80BF1284:("func_80BF1284",), + 0x80BF1258:("EnIg_UpdateSkelAnime",), + 0x80BF1284:("EnIg_ChangeAnim",), 0x80BF1354:("func_80BF1354",), 0x80BF13E4:("func_80BF13E4",), 0x80BF146C:("func_80BF146C",), From 33aaaea2c40228e4df2b3508b3f206eaf4186d92 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Sat, 30 Sep 2023 17:28:14 +1000 Subject: [PATCH 7/9] Start Player Item Docs (#1396) * Copy Fig Docs * small cleanup * ItemChangeType comment * bool * item change comments * PR Review * rm comments --- include/functions.h | 2 +- include/z64player.h | 12 +- src/code/z_player_lib.c | 26 +- .../actors/ovl_player_actor/z_player.c | 588 ++++++++++-------- tools/disasm/functions.txt | 32 +- tools/disasm/variables.txt | 18 +- tools/sizes/code_functions.csv | 2 +- 7 files changed, 387 insertions(+), 293 deletions(-) diff --git a/include/functions.h b/include/functions.h index 88d8468e9..849329d94 100644 --- a/include/functions.h +++ b/include/functions.h @@ -884,7 +884,7 @@ s32 func_80123448(PlayState* play); s32 Player_IsGoronOrDeku(Player* player); s32 func_801234D4(PlayState* play); s32 func_80123590(PlayState* play, Actor* actor); -ItemId func_8012364C(PlayState* play, Player* player, s32 arg2); +ItemId Player_GetItemOnButton(PlayState* play, Player* player, EquipSlot slot); PlayerItemAction func_80123810(PlayState* play); PlayerModelGroup Player_ActionToModelGroup(Player* player, PlayerItemAction itemAction); void Player_SetModelsForHoldingShield(Player* player); diff --git a/include/z64player.h b/include/z64player.h index 11145480e..3f0af150a 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -1040,7 +1040,7 @@ typedef enum PlayerCueId { // breman mask march? #define PLAYER_STATE3_20000000 (1 << 29) // -#define PLAYER_STATE3_40000000 (1 << 30) +#define PLAYER_STATE3_START_CHANGING_HELD_ITEM (1 << 30) // TARGETING_HOSTILE? #define PLAYER_STATE3_80000000 (1 << 31) @@ -1095,7 +1095,7 @@ typedef struct Player { /* 0x14B */ u8 transformation; // PlayerTransformation enum /* 0x14C */ u8 modelGroup; // PlayerModelGroup enum /* 0x14D */ u8 nextModelGroup; - /* 0x14E */ s8 unk_14E; + /* 0x14E */ s8 itemChangeType; // ItemChangeType enum /* 0x14F */ u8 modelAnimType; // PlayerAnimType enum /* 0x150 */ u8 leftHandType; /* 0x151 */ u8 rightHandType; @@ -1122,7 +1122,7 @@ typedef struct Player { /* 0x238 */ OSMesg maskObjectLoadMsg; /* 0x23C */ void* maskObjectSegment; /* 0x240 */ SkelAnime skelAnime; - /* 0x284 */ SkelAnime unk_284; + /* 0x284 */ SkelAnime skelAnimeUpper; /* 0x2C8 */ SkelAnime unk_2C8; /* 0x30C */ Vec3s jointTable[5]; /* 0x32A */ Vec3s morphTable[5]; @@ -1176,8 +1176,8 @@ typedef struct Player { /* 0x74C */ u8 jointTableBuffer[PLAYER_LIMB_BUF_SIZE]; /* 0x7EB */ u8 morphTableBuffer[PLAYER_LIMB_BUF_SIZE]; /* 0x88A */ u8 blendTableBuffer[PLAYER_LIMB_BUF_SIZE]; - /* 0x929 */ u8 unk_929[PLAYER_LIMB_BUF_SIZE]; - /* 0x9C8 */ u8 unk_9C8[PLAYER_LIMB_BUF_SIZE]; + /* 0x929 */ u8 jointTableUpperBuffer[PLAYER_LIMB_BUF_SIZE]; + /* 0x9C8 */ u8 morphTableUpperBuffer[PLAYER_LIMB_BUF_SIZE]; /* 0xA68 */ PlayerAgeProperties* ageProperties; // repurposed as "transformation properties"? /* 0xA6C */ u32 stateFlags1; /* 0xA70 */ u32 stateFlags2; @@ -1206,7 +1206,7 @@ typedef struct Player { /* 0xABC */ f32 unk_ABC; /* 0xAC0 */ f32 unk_AC0; /* 0xAC4 */ PlayerUpperActionFunc upperActionFunc; // Upper body/item action functions - /* 0xAC8 */ f32 unk_AC8; + /* 0xAC8 */ f32 skelAnimeUpperBlendWeight; /* 0xACC */ s16 unk_ACC; /* 0xACE */ s8 unk_ACE; /* 0xACF */ u8 putAwayCountdown; // Frames to wait before showing "Put Away" on A diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index db9a8c974..24b55cfea 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -570,12 +570,12 @@ s32 func_801235DC(PlayState* play, f32 arg1, s16 arg2) { return false; } -ItemId func_8012364C(PlayState* play, Player* player, s32 arg2) { - if (arg2 >= 4) { +ItemId Player_GetItemOnButton(PlayState* play, Player* player, EquipSlot slot) { + if (slot >= EQUIP_SLOT_A) { return ITEM_NONE; } - if (arg2 == 0) { + if (slot == EQUIP_SLOT_B) { ItemId item = Inventory_GetBtnBItem(play); if (item >= ITEM_FD) { @@ -597,18 +597,24 @@ ItemId func_8012364C(PlayState* play, Player* player, s32 arg2) { return item; } - if (arg2 == 1) { + if (slot == EQUIP_SLOT_C_LEFT) { return C_BTN_ITEM(EQUIP_SLOT_C_LEFT); } - if (arg2 == 2) { + if (slot == EQUIP_SLOT_C_DOWN) { return C_BTN_ITEM(EQUIP_SLOT_C_DOWN); } + // EQUIP_SLOT_C_RIGHT + return C_BTN_ITEM(EQUIP_SLOT_C_RIGHT); } -u16 sCItemButtons[] = { BTN_CLEFT, BTN_CDOWN, BTN_CRIGHT }; +u16 sCItemButtons[] = { + BTN_CLEFT, + BTN_CDOWN, + BTN_CRIGHT, +}; PlayerItemAction func_80123810(PlayState* play) { Player* player = GET_PLAYER(play); @@ -630,7 +636,7 @@ PlayerItemAction func_80123810(PlayState* play) { for (i = 0; i < ARRAY_COUNT(sCItemButtons); i++) { if (CHECK_BTN_ALL(CONTROLLER1(&play->state)->press.button, sCItemButtons[i])) { i++; - itemId = func_8012364C(play, player, i); + itemId = Player_GetItemOnButton(play, player, i); play->interfaceCtx.unk_222 = 0; play->interfaceCtx.unk_224 = 0; @@ -2092,7 +2098,7 @@ s32 Player_OverrideLimbDrawGameplayCommon(PlayState* play, s32 limbIndex, Gfx** EnArrow* bubble = NULL; if (((player->skelAnime.animation == &gPlayerAnim_pn_drinkend)) || - (player->unk_284.animation == &gPlayerAnim_pn_tamahaki) || + (player->skelAnimeUpper.animation == &gPlayerAnim_pn_tamahaki) || ((player->stateFlags3 & PLAYER_STATE3_40) && ((bubble = (EnArrow*)player->heldActor) != NULL))) { Matrix_TranslateRotateZYX(pos, rot); func_80125340(); @@ -2108,7 +2114,7 @@ s32 Player_OverrideLimbDrawGameplayCommon(PlayState* play, s32 limbIndex, Gfx** } else if (player->skelAnime.animation == &gPlayerAnim_pn_drinkend) { func_80124618(D_801C03E0, player->skelAnime.curFrame, player->unk_AF0); } else { - func_80124618(D_801C03C0, player->unk_284.curFrame, player->unk_AF0); + func_80124618(D_801C03C0, player->skelAnimeUpper.curFrame, player->unk_AF0); } Matrix_Scale(player->unk_AF0[0].x, player->unk_AF0[0].y, player->unk_AF0[0].z, MTXMODE_APPLY); @@ -3784,7 +3790,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, G Matrix_MultVec3f(&sPlayerFocusHeadLimbModelPos, &player->actor.focus.pos); Matrix_MultVec3f(&D_801C0E94, sPlayerCurBodyPartPos); if ((player->skelAnime.animation == &gPlayerAnim_pn_drinkend) || - (player->unk_284.animation == &gPlayerAnim_pn_tamahaki) || + (player->skelAnimeUpper.animation == &gPlayerAnim_pn_tamahaki) || ((player->stateFlags3 & PLAYER_STATE3_40) && ((spA8 = player->heldActor) != NULL))) { if (spA8 != NULL) { static Vec3f D_801C0EA0 = { 1300.0f, -400.0f, 0.0f }; diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 8c1de93e5..d01dbd3be 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -64,9 +64,9 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input); s32 Player_StartFishing(PlayState* play); void func_8085B170(PlayState* play, Player* this); s32 func_8083A658(PlayState* play, Player* this); -void func_8082F8BC(PlayState* play, Player* this, PlayerItemAction itemAction); +void Player_InitItemAction(PlayState* play, Player* this, PlayerItemAction itemAction); -void func_80831990(PlayState* play, Player* this, ItemId item); +void Player_UseItem(PlayState* play, Player* this, ItemId item); void func_80836988(Player* this, PlayState* play); @@ -210,7 +210,7 @@ void Player_Action_97(Player* this, PlayState* play); s32 Player_UpperAction_0(Player* this, PlayState* play); s32 Player_UpperAction_1(Player* this, PlayState* play); -s32 Player_UpperAction_2(Player* this, PlayState* play); +s32 Player_UpperAction_ChangeHeldItem(Player* this, PlayState* play); s32 Player_UpperAction_3(Player* this, PlayState* play); s32 Player_UpperAction_4(Player* this, PlayState* play); s32 Player_UpperAction_5(Player* this, PlayState* play); @@ -468,10 +468,10 @@ typedef struct MeleeWeaponDamageInfo { /* 0x7 */ u8 dmgHumanStrong; } MeleeWeaponDamageInfo; // size = 0x8 -typedef struct struct_8085CC88 { +typedef struct ItemChangeInfo { /* 0x0 */ PlayerAnimationHeader* anim; - /* 0x4 */ u8 frame; -} struct_8085CC88; // size = 0x8 + /* 0x4 */ u8 changeFrame; +} ItemChangeInfo; // size = 0x8 typedef struct { /* 0x0 */ u8 itemId; @@ -504,7 +504,7 @@ typedef struct struct_8085D200 { f32 sPlayerControlStickMagnitude; s16 sPlayerControlStickAngle; s16 D_80862B02; // analog stick yaw + camera yaw -s32 D_80862B04; // boolean, set to the return value of func_8083216C +s32 D_80862B04; // boolean, set to the return value of Player_UpdateUpperBody FloorType sPlayerFloorType; u32 sPlayerTouchedWallFlags; ConveyorSpeed sPlayerConveyorSpeedIndex; @@ -520,10 +520,10 @@ Vec3f sPlayerInteractWallCheckResult; f32 D_80862B3C; FloorEffect sPlayerFloorEffect; Input* sPlayerControlInput; -s32 D_80862B48; -s32 D_80862B4C; -EnvLightSettings D_80862B50; // backup of play->envCtx.lightSettings -s32 D_80862B6C; // this->skelAnime.moveFlags // sPlayerSkelMoveFlags? +s32 sPlayerUseHeldItem; // When true, the current held item is used. Is reset to false every frame. +s32 sPlayerHeldItemButtonIsHeldDown; // Indicates if the button for the current held item is held down. +EnvLightSettings D_80862B50; // backup of play->envCtx.lightSettings +s32 D_80862B6C; // this->skelAnime.moveFlags // sPlayerSkelMoveFlags? s32 func_8082DA90(PlayState* play) { return (play->transitionTrigger != TRANS_TRIGGER_OFF) || (play->transitionMode != TRANS_MODE_OFF); @@ -586,7 +586,7 @@ void func_8082DC64(PlayState* play, Player* this) { this->stateFlags2 &= ~(PLAYER_STATE2_400 | PLAYER_STATE2_800); } -void func_8082DCA0(PlayState* play, Player* this) { +void Player_DetachHeldActor(PlayState* play, Player* this) { Actor* heldActor = this->heldActor; if ((heldActor != NULL) && !Player_IsHoldingHookshot(this)) { @@ -598,7 +598,7 @@ void func_8082DCA0(PlayState* play, Player* this) { } if (Player_GetExplosiveHeld(this) > PLAYER_EXPLOSIVE_NONE) { - func_8082F8BC(play, this, PLAYER_IA_NONE); + Player_InitItemAction(play, this, PLAYER_IA_NONE); this->heldItemId = ITEM_FE; } } @@ -632,7 +632,7 @@ void func_8082DD2C(PlayState* play, Player* this) { s32 func_8082DE14(PlayState* play, Player* this) { if (this->heldItemAction > PLAYER_IA_LAST_USED) { - func_80831990(play, this, ITEM_NONE); + Player_UseItem(play, this, ITEM_NONE); return true; } else { return false; @@ -641,7 +641,7 @@ s32 func_8082DE14(PlayState* play, Player* this) { void func_8082DE50(PlayState* play, Player* this) { func_8082DD2C(play, this); - func_8082DCA0(play, this); + Player_DetachHeldActor(play, this); } s32 func_8082DE88(Player* this, s32 arg1, s32 arg2) { @@ -663,7 +663,7 @@ void func_8082DF2C(PlayState* play) { } } -u8 D_8085B9F0[PLAYER_LIMB_MAX] = { +u8 sPlayerUpperBodyLimbCopyMap[PLAYER_LIMB_MAX] = { false, // PLAYER_LIMB_NONE false, // PLAYER_LIMB_ROOT false, // PLAYER_LIMB_WAIST @@ -2863,30 +2863,30 @@ void func_8082F1AC(PlayState* play, Player* this) { void Player_SetUpperAction(PlayState* play, Player* this, PlayerUpperActionFunc upperActionFunc) { this->upperActionFunc = upperActionFunc; this->unk_ACE = 0; - this->unk_AC8 = 0.0f; + this->skelAnimeUpperBlendWeight = 0.0f; func_8082E00C(this); } #define GET_PLAYER_ANIM(group, type) ((PlayerAnimationHeader**)D_8085BE84)[group * PLAYER_ANIMTYPE_MAX + type] -void func_8082F470(PlayState* play, Player* this, PlayerItemAction itemAction) { +void Player_InitItemActionWithAnim(PlayState* play, Player* this, PlayerItemAction itemAction) { PlayerAnimationHeader* curAnim = this->skelAnime.animation; PlayerAnimationHeader*(*iter)[PLAYER_ANIMTYPE_MAX] = (void*)&D_8085BE84[0][this->modelAnimType]; - s32 i; + s32 animGroup; this->stateFlags1 &= ~(PLAYER_STATE1_8 | PLAYER_STATE1_1000000); - for (i = 0; i < PLAYER_ANIMGROUP_MAX; i++) { + for (animGroup = 0; animGroup < PLAYER_ANIMGROUP_MAX; animGroup++) { if (curAnim == **iter) { break; } iter++; } - func_8082F8BC(play, this, itemAction); + Player_InitItemAction(play, this, itemAction); - if (i < PLAYER_ANIMGROUP_MAX) { - this->skelAnime.animation = GET_PLAYER_ANIM(i, this->modelAnimType); + if (animGroup < PLAYER_ANIMGROUP_MAX) { + this->skelAnime.animation = GET_PLAYER_ANIM(animGroup, this->modelAnimType); } } @@ -2988,7 +2988,7 @@ PlayerItemAction Player_ItemToItemAction(Player* this, ItemId item) { } } -PlayerUpperActionFunc D_8085C9F0[PLAYER_IA_MAX] = { +PlayerUpperActionFunc sPlayerUpperActionUpdateFuncs[PLAYER_IA_MAX] = { Player_UpperAction_0, // PLAYER_IA_NONE Player_UpperAction_0, // PLAYER_IA_LAST_USED Player_UpperAction_0, // PLAYER_IA_FISHING_ROD @@ -3076,7 +3076,7 @@ PlayerUpperActionFunc D_8085C9F0[PLAYER_IA_MAX] = { typedef void (*PlayerInitItemActionFunc)(PlayState*, Player*); -PlayerInitItemActionFunc sPlayerInitItemActionFuncs[PLAYER_IA_MAX] = { +PlayerInitItemActionFunc sPlayerItemActionInitFuncs[PLAYER_IA_MAX] = { Player_InitItemAction_DoNothing, // PLAYER_IA_NONE Player_InitItemAction_DoNothing, // PLAYER_IA_LAST_USED Player_InitItemAction_DoNothing, // PLAYER_IA_FISHING_ROD @@ -3189,27 +3189,94 @@ void func_8082F5FC(Player* this, Actor* actor) { this->stateFlags1 |= PLAYER_STATE1_800; } -struct_8085CC88 D_8085CC88[] = { - { &gPlayerAnim_link_normal_free2free, 12 }, - { &gPlayerAnim_link_normal_normal2fighter, 6 }, - { &gPlayerAnim_link_hammer_normal2long, 8 }, - { &gPlayerAnim_link_normal_normal2free, 8 }, - { &gPlayerAnim_link_fighter_fighter2long, 8 }, - { &gPlayerAnim_link_normal_fighter2free, 10 }, - { &gPlayerAnim_link_hammer_long2free, 7 }, - { &gPlayerAnim_link_hammer_long2long, 11 }, - { &gPlayerAnim_link_normal_free2free, 12 }, - { &gPlayerAnim_link_normal_normal2bom, 4 }, - { &gPlayerAnim_link_normal_long2bom, 4 }, - { &gPlayerAnim_link_normal_free2bom, 4 }, - { &gPlayerAnim_link_anchor_anchor2fighter, 5 }, - { &gPlayerAnim_link_normal_free2freeB, 13 }, - { &gPlayerAnim_pz_bladeon, 4 }, +typedef enum ItemChangeType { + /* 0 */ PLAYER_ITEM_CHG_0, + /* 1 */ PLAYER_ITEM_CHG_1, + /* 2 */ PLAYER_ITEM_CHG_2, + /* 3 */ PLAYER_ITEM_CHG_3, + /* 4 */ PLAYER_ITEM_CHG_4, + /* 5 */ PLAYER_ITEM_CHG_5, + /* 6 */ PLAYER_ITEM_CHG_6, + /* 7 */ PLAYER_ITEM_CHG_7, + /* 8 */ PLAYER_ITEM_CHG_8, + /* 9 */ PLAYER_ITEM_CHG_9, + /* 10 */ PLAYER_ITEM_CHG_10, + /* 11 */ PLAYER_ITEM_CHG_11, + /* 12 */ PLAYER_ITEM_CHG_12, + /* 13 */ PLAYER_ITEM_CHG_13, + /* 14 */ PLAYER_ITEM_CHG_14, + /* 15 */ PLAYER_ITEM_CHG_MAX +} ItemChangeType; + +ItemChangeInfo sPlayerItemChangeInfo[PLAYER_ITEM_CHG_MAX] = { + { &gPlayerAnim_link_normal_free2free, 12 }, // PLAYER_ITEM_CHG_0 + { &gPlayerAnim_link_normal_normal2fighter, 6 }, // PLAYER_ITEM_CHG_1 + { &gPlayerAnim_link_hammer_normal2long, 8 }, // PLAYER_ITEM_CHG_2 + { &gPlayerAnim_link_normal_normal2free, 8 }, // PLAYER_ITEM_CHG_3 + { &gPlayerAnim_link_fighter_fighter2long, 8 }, // PLAYER_ITEM_CHG_4 + { &gPlayerAnim_link_normal_fighter2free, 10 }, // PLAYER_ITEM_CHG_5 + { &gPlayerAnim_link_hammer_long2free, 7 }, // PLAYER_ITEM_CHG_6 + { &gPlayerAnim_link_hammer_long2long, 11 }, // PLAYER_ITEM_CHG_7 + { &gPlayerAnim_link_normal_free2free, 12 }, // PLAYER_ITEM_CHG_8 + { &gPlayerAnim_link_normal_normal2bom, 4 }, // PLAYER_ITEM_CHG_9 + { &gPlayerAnim_link_normal_long2bom, 4 }, // PLAYER_ITEM_CHG_10 + { &gPlayerAnim_link_normal_free2bom, 4 }, // PLAYER_ITEM_CHG_11 + { &gPlayerAnim_link_anchor_anchor2fighter, 5 }, // PLAYER_ITEM_CHG_12 + { &gPlayerAnim_link_normal_free2freeB, 13 }, // PLAYER_ITEM_CHG_13 + { &gPlayerAnim_pz_bladeon, 4 }, // PLAYER_ITEM_CHG_14 }; -s8 D_8085CD00[PLAYER_ANIMTYPE_MAX][PLAYER_ANIMTYPE_MAX] = { - { 8, -5, -3, -6, 8, 0xB }, { 5, 0, -1, 4, 5, 9 }, { 3, 1, 0, 2, 3, 9 }, - { 6, -4, -2, 7, 6, 0xA }, { 8, -5, -3, -6, 8, 0xB }, { 8, -5, -3, -6, 8, 0xB }, +// Maps the appropriate ItemChangeType based on current and next animtype. +// A negative type value means the corresponding animation should be played in reverse. +s8 sPlayerItemChangeTypes[PLAYER_ANIMTYPE_MAX][PLAYER_ANIMTYPE_MAX] = { + { + PLAYER_ITEM_CHG_8, // PLAYER_ANIMTYPE_DEFAULT -> PLAYER_ANIMTYPE_DEFAULT + -PLAYER_ITEM_CHG_5, // PLAYER_ANIMTYPE_DEFAULT -> PLAYER_ANIMTYPE_1 + -PLAYER_ITEM_CHG_3, // PLAYER_ANIMTYPE_DEFAULT -> PLAYER_ANIMTYPE_2 + -PLAYER_ITEM_CHG_6, // PLAYER_ANIMTYPE_DEFAULT -> PLAYER_ANIMTYPE_3 + PLAYER_ITEM_CHG_8, // PLAYER_ANIMTYPE_DEFAULT -> PLAYER_ANIMTYPE_4 + PLAYER_ITEM_CHG_11, // PLAYER_ANIMTYPE_DEFAULT -> PLAYER_ANIMTYPE_5 + }, + { + PLAYER_ITEM_CHG_5, // PLAYER_ANIMTYPE_1 -> PLAYER_ANIMTYPE_DEFAULT + PLAYER_ITEM_CHG_0, // PLAYER_ANIMTYPE_1 -> PLAYER_ANIMTYPE_1 + -PLAYER_ITEM_CHG_1, // PLAYER_ANIMTYPE_1 -> PLAYER_ANIMTYPE_2 + PLAYER_ITEM_CHG_4, // PLAYER_ANIMTYPE_1 -> PLAYER_ANIMTYPE_3 + PLAYER_ITEM_CHG_5, // PLAYER_ANIMTYPE_1 -> PLAYER_ANIMTYPE_4 + PLAYER_ITEM_CHG_9, // PLAYER_ANIMTYPE_1 -> PLAYER_ANIMTYPE_5 + }, + { + PLAYER_ITEM_CHG_3, // PLAYER_ANIMTYPE_2 -> PLAYER_ANIMTYPE_DEFAULT + PLAYER_ITEM_CHG_1, // PLAYER_ANIMTYPE_2 -> PLAYER_ANIMTYPE_1 + PLAYER_ITEM_CHG_0, // PLAYER_ANIMTYPE_2 -> PLAYER_ANIMTYPE_2 + PLAYER_ITEM_CHG_2, // PLAYER_ANIMTYPE_2 -> PLAYER_ANIMTYPE_3 + PLAYER_ITEM_CHG_3, // PLAYER_ANIMTYPE_2 -> PLAYER_ANIMTYPE_4 + PLAYER_ITEM_CHG_9, // PLAYER_ANIMTYPE_2 -> PLAYER_ANIMTYPE_5 + }, + { + PLAYER_ITEM_CHG_6, // PLAYER_ANIMTYPE_3 -> PLAYER_ANIMTYPE_DEFAULT + -PLAYER_ITEM_CHG_4, // PLAYER_ANIMTYPE_3 -> PLAYER_ANIMTYPE_1 + -PLAYER_ITEM_CHG_2, // PLAYER_ANIMTYPE_3 -> PLAYER_ANIMTYPE_2 + PLAYER_ITEM_CHG_7, // PLAYER_ANIMTYPE_3 -> PLAYER_ANIMTYPE_3 + PLAYER_ITEM_CHG_6, // PLAYER_ANIMTYPE_3 -> PLAYER_ANIMTYPE_4 + PLAYER_ITEM_CHG_10, // PLAYER_ANIMTYPE_3 -> PLAYER_ANIMTYPE_5 + }, + { + PLAYER_ITEM_CHG_8, // PLAYER_ANIMTYPE_4 -> PLAYER_ANIMTYPE_DEFAULT + -PLAYER_ITEM_CHG_5, // PLAYER_ANIMTYPE_4 -> PLAYER_ANIMTYPE_1 + -PLAYER_ITEM_CHG_3, // PLAYER_ANIMTYPE_4 -> PLAYER_ANIMTYPE_2 + -PLAYER_ITEM_CHG_6, // PLAYER_ANIMTYPE_4 -> PLAYER_ANIMTYPE_3 + PLAYER_ITEM_CHG_8, // PLAYER_ANIMTYPE_4 -> PLAYER_ANIMTYPE_4 + PLAYER_ITEM_CHG_11, // PLAYER_ANIMTYPE_4 -> PLAYER_ANIMTYPE_5 + }, + { + PLAYER_ITEM_CHG_8, // PLAYER_ANIMTYPE_5 -> PLAYER_ANIMTYPE_DEFAULT + -PLAYER_ITEM_CHG_5, // PLAYER_ANIMTYPE_5 -> PLAYER_ANIMTYPE_1 + -PLAYER_ITEM_CHG_3, // PLAYER_ANIMTYPE_5 -> PLAYER_ANIMTYPE_2 + -PLAYER_ITEM_CHG_6, // PLAYER_ANIMTYPE_5 -> PLAYER_ANIMTYPE_3 + PLAYER_ITEM_CHG_8, // PLAYER_ANIMTYPE_5 -> PLAYER_ANIMTYPE_4 + PLAYER_ITEM_CHG_11, // PLAYER_ANIMTYPE_5 -> PLAYER_ANIMTYPE_5 + }, }; ExplosiveInfo sPlayerExplosiveInfo[PLAYER_EXPLOSIVE_MAX] = { @@ -3271,7 +3338,7 @@ void Player_InitItemAction_SpawnHookshot(PlayState* play, Player* this) { this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, 0); if (this->heldActor == NULL) { - func_80831990(play, this, ITEM_NONE); + Player_UseItem(play, this, ITEM_NONE); return; } armsHook = (ArmsHook*)this->heldActor; @@ -3283,7 +3350,7 @@ void Player_InitItemAction_5(PlayState* play, Player* this) { this->stateFlags1 |= PLAYER_STATE1_1000000; } -void func_8082F8BC(PlayState* play, Player* this, PlayerItemAction itemAction) { +void Player_InitItemAction(PlayState* play, Player* this, PlayerItemAction itemAction) { this->itemAction = this->heldItemAction = itemAction; this->modelGroup = this->nextModelGroup; @@ -3293,7 +3360,7 @@ void func_8082F8BC(PlayState* play, Player* this, PlayerItemAction itemAction) { this->unk_B0C = 0.0f; this->unk_B28 = 0; - sPlayerInitItemActionFuncs[itemAction](play, this); + sPlayerItemActionInitFuncs[itemAction](play, this); Player_SetModelGroup(this, this->modelGroup); } @@ -3528,7 +3595,7 @@ void func_8082FC60(Player* this) { this->unk_B40 = 0.0f; } -s32 func_8082FC78(Player* this, ItemId item) { +s32 Player_ItemIsInUse(Player* this, ItemId item) { if ((item < ITEM_FD) && (Player_ItemToItemAction(this, item) == this->itemAction)) { return true; } else { @@ -3536,7 +3603,7 @@ s32 func_8082FC78(Player* this, ItemId item) { } } -s32 func_8082FCC4(Player* this, ItemId item, PlayerItemAction itemAction) { +s32 Player_ItemIsItemAction(Player* this, ItemId item, PlayerItemAction itemAction) { if ((item < ITEM_FD) && (Player_ItemToItemAction(this, item) == itemAction)) { return true; } else { @@ -3548,7 +3615,7 @@ EquipSlot func_8082FD0C(Player* this, PlayerItemAction itemAction) { s32 btn; for (btn = EQUIP_SLOT_C_LEFT; btn <= EQUIP_SLOT_C_RIGHT; btn++) { - if (func_8082FCC4(this, GET_CUR_FORM_BTN_ITEM(btn), itemAction)) { + if (Player_ItemIsItemAction(this, GET_CUR_FORM_BTN_ITEM(btn), itemAction)) { return btn; } } @@ -3556,7 +3623,7 @@ EquipSlot func_8082FD0C(Player* this, PlayerItemAction itemAction) { return EQUIP_SLOT_NONE; } -u16 D_8085CFA8[] = { +u16 sPlayerItemButtons[] = { BTN_B, BTN_CLEFT, BTN_CDOWN, @@ -3567,8 +3634,8 @@ u16 D_8085CFA8[] = { EquipSlot func_8082FDC4(void) { EquipSlot i; - for (i = 0; i < ARRAY_COUNT(D_8085CFA8); i++) { - if (CHECK_BTN_ALL(sPlayerControlInput->press.button, D_8085CFA8[i])) { + for (i = 0; i < ARRAY_COUNT(sPlayerItemButtons); i++) { + if (CHECK_BTN_ALL(sPlayerControlInput->press.button, sPlayerItemButtons[i])) { break; } } @@ -3576,7 +3643,10 @@ EquipSlot func_8082FDC4(void) { return i; } -void func_8082FE0C(Player* this, PlayState* play) { +/** + * Handles the high level item usage and changing process based on the B and C buttons. + */ +void Player_ProcessItemButtons(Player* this, PlayState* play) { if (this->stateFlags1 & (PLAYER_STATE1_800 | PLAYER_STATE1_20000000)) { return; } @@ -3602,7 +3672,7 @@ void func_8082FE0C(Player* this, PlayState* play) { if ((maskIdMinusOne < PLAYER_MASK_TRUTH - 1) || (maskIdMinusOne >= PLAYER_MASK_MAX - 1)) { maskIdMinusOne = this->currentMask - 1; } - func_80831990(play, this, Player_MaskIdToItemId(maskIdMinusOne)); + Player_UseItem(play, this, Player_MaskIdToItemId(maskIdMinusOne)); return; } @@ -3616,10 +3686,11 @@ void func_8082FE0C(Player* this, PlayState* play) { if (((this->actor.id == ACTOR_PLAYER) && (this->itemAction >= PLAYER_IA_FISHING_ROD)) && !(((Player_GetHeldBButtonSword(this) == PLAYER_B_SWORD_NONE) || (gSaveContext.jinxTimer == 0)) && - (func_8082FC78(this, (IREG(1) != 0) ? ITEM_FISHING_ROD : Inventory_GetBtnBItem(play)) || - func_8082FC78(this, C_BTN_ITEM(EQUIP_SLOT_C_LEFT)) || func_8082FC78(this, C_BTN_ITEM(EQUIP_SLOT_C_DOWN)) || - func_8082FC78(this, C_BTN_ITEM(EQUIP_SLOT_C_RIGHT))))) { - func_80831990(play, this, ITEM_NONE); + (Player_ItemIsInUse(this, (IREG(1) != 0) ? ITEM_FISHING_ROD : Inventory_GetBtnBItem(play)) || + Player_ItemIsInUse(this, C_BTN_ITEM(EQUIP_SLOT_C_LEFT)) || + Player_ItemIsInUse(this, C_BTN_ITEM(EQUIP_SLOT_C_DOWN)) || + Player_ItemIsInUse(this, C_BTN_ITEM(EQUIP_SLOT_C_RIGHT))))) { + Player_UseItem(play, this, ITEM_NONE); } else { s32 pad; ItemId item; @@ -3630,17 +3701,18 @@ void func_8082FE0C(Player* this, PlayState* play) { ? EQUIP_SLOT_B : i; - item = func_8012364C(play, this, i); + item = Player_GetItemOnButton(play, this, i); + if (item >= ITEM_FD) { - for (i = 0; i < ARRAY_COUNT(D_8085CFA8); i++) { - if (CHECK_BTN_ALL(sPlayerControlInput->cur.button, D_8085CFA8[i])) { + for (i = 0; i < ARRAY_COUNT(sPlayerItemButtons); i++) { + if (CHECK_BTN_ALL(sPlayerControlInput->cur.button, sPlayerItemButtons[i])) { break; } } - item = func_8012364C(play, this, i); + item = Player_GetItemOnButton(play, this, i); if ((item < ITEM_FD) && (Player_ItemToItemAction(this, item) == this->heldItemAction)) { - D_80862B4C = 1; + sPlayerHeldItemButtonIsHeldDown = true; } } else if (item == ITEM_F0) { if (this->blastMaskTimer == 0) { @@ -3664,44 +3736,45 @@ void func_8082FE0C(Player* this, PlayState* play) { } } else { this->heldItemButton = i; - func_80831990(play, this, item); + Player_UseItem(play, this, item); } } } -void func_808302CC(Player* this, PlayState* play) { +void Player_StartChangingHeldItem(Player* this, PlayState* play) { PlayerAnimationHeader* anim; s32 pad[3]; u8 nextModelAnimType; - s32 var_v1; - s8 itemAction = Player_ItemToItemAction(this, this->heldItemId); + s32 itemChangeType; + s8 heldItemAction = Player_ItemToItemAction(this, this->heldItemId); s32 pad3; f32 startFrame; f32 endFrame; f32 frameSpeed; - Player_SetUpperAction(play, this, Player_UpperAction_2); + Player_SetUpperAction(play, this, Player_UpperAction_ChangeHeldItem); nextModelAnimType = gPlayerModelTypes[this->nextModelGroup].modelAnimType; - var_v1 = D_8085CD00[gPlayerModelTypes[this->modelGroup].modelAnimType][nextModelAnimType]; + itemChangeType = sPlayerItemChangeTypes[gPlayerModelTypes[this->modelGroup].modelAnimType][nextModelAnimType]; - if ((itemAction == PLAYER_IA_ZORA_FINS) || (this->heldItemAction == PLAYER_IA_ZORA_FINS)) { - var_v1 = (itemAction == PLAYER_IA_NONE) ? -14 : 14; - } else if ((itemAction == PLAYER_IA_BOTTLE_EMPTY) || (itemAction == PLAYER_IA_11) || - ((itemAction == PLAYER_IA_NONE) && + if ((heldItemAction == PLAYER_IA_ZORA_FINS) || (this->heldItemAction == PLAYER_IA_ZORA_FINS)) { + itemChangeType = (heldItemAction == PLAYER_IA_NONE) ? -PLAYER_ITEM_CHG_14 : PLAYER_ITEM_CHG_14; + } else if ((heldItemAction == PLAYER_IA_BOTTLE_EMPTY) || (heldItemAction == PLAYER_IA_11) || + ((heldItemAction == PLAYER_IA_NONE) && ((this->heldItemAction == PLAYER_IA_BOTTLE_EMPTY) || (this->heldItemAction == PLAYER_IA_11)))) { - var_v1 = (itemAction == PLAYER_IA_NONE) ? -13 : 13; + itemChangeType = (heldItemAction == PLAYER_IA_NONE) ? -PLAYER_ITEM_CHG_13 : PLAYER_ITEM_CHG_13; } - this->unk_14E = ABS_ALT(var_v1); - anim = D_8085CC88[this->unk_14E].anim; + this->itemChangeType = ABS_ALT(itemChangeType); + anim = sPlayerItemChangeInfo[this->itemChangeType].anim; + if ((anim == &gPlayerAnim_link_normal_fighter2free) && (this->currentShield == PLAYER_SHIELD_NONE)) { anim = &gPlayerAnim_link_normal_free2fighter_free; } endFrame = Animation_GetLastFrame(anim); - if (var_v1 >= 0) { + if (itemChangeType >= 0) { frameSpeed = 1.2f; startFrame = 0.0f; } else { @@ -3710,30 +3783,31 @@ void func_808302CC(Player* this, PlayState* play) { endFrame = 0.0f; } - if (itemAction != PLAYER_IA_NONE) { + if (heldItemAction != PLAYER_IA_NONE) { frameSpeed *= 2.0f; } - PlayerAnimation_Change(play, &this->unk_284, anim, frameSpeed, startFrame, endFrame, ANIMMODE_ONCE, 0.0f); - this->stateFlags3 &= ~PLAYER_STATE3_40000000; + PlayerAnimation_Change(play, &this->skelAnimeUpper, anim, frameSpeed, startFrame, endFrame, ANIMMODE_ONCE, 0.0f); + + this->stateFlags3 &= ~PLAYER_STATE3_START_CHANGING_HELD_ITEM; } -void func_808304BC(Player* this, PlayState* play) { - if ((this->actor.id == ACTOR_PLAYER) && !(this->stateFlags3 & PLAYER_STATE3_40000000)) { +void Player_UpdateItems(Player* this, PlayState* play) { + if ((this->actor.id == ACTOR_PLAYER) && !(this->stateFlags3 & PLAYER_STATE3_START_CHANGING_HELD_ITEM)) { if ((this->heldItemAction == this->itemAction) || (this->stateFlags1 & PLAYER_STATE1_400000)) { if ((gSaveContext.save.saveInfo.playerData.health != 0) && (play->csCtx.state == CS_STATE_IDLE)) { if ((this->csMode == PLAYER_CSMODE_NONE) && (play->unk_1887C == 0) && (play->activeCamId == CAM_ID_MAIN)) { if (!func_8082DA90(play) && (gSaveContext.timerStates[TIMER_ID_MINIGAME_2] != TIMER_STATE_STOP)) { - func_8082FE0C(this, play); + Player_ProcessItemButtons(this, play); } } } } } - if (this->stateFlags3 & PLAYER_STATE3_40000000) { - func_808302CC(this, play); + if (this->stateFlags3 & PLAYER_STATE3_START_CHANGING_HELD_ITEM) { + Player_StartChangingHeldItem(this, play); } } @@ -3836,8 +3910,7 @@ s32 func_808306F8(Player* this, PlayState* play) { return false; } -// Take out / put away sounds? -void func_808308DC(PlayState* play, Player* this) { +void Player_FinishItemChange(PlayState* play, Player* this) { s32 isGoronOrDeku = (this->transformation == PLAYER_FORM_GORON) || (this->transformation == PLAYER_FORM_DEKU); if ((this->heldItemAction != PLAYER_IA_NONE) && !isGoronOrDeku) { @@ -3848,7 +3921,7 @@ void func_808308DC(PlayState* play, Player* this) { } } - func_80831990(play, this, this->heldItemId); + Player_UseItem(play, this, this->heldItemId); if (!isGoronOrDeku) { if (Player_SwordFromIA(this, this->heldItemAction) > PLAYER_SWORD_NONE) { @@ -3860,15 +3933,15 @@ void func_808308DC(PlayState* play, Player* this) { } void func_808309CC(PlayState* play, Player* this) { - if (Player_UpperAction_2 == this->upperActionFunc) { - func_808308DC(play, this); + if (Player_UpperAction_ChangeHeldItem == this->upperActionFunc) { + Player_FinishItemChange(play, this); } - Player_SetUpperAction(play, this, D_8085C9F0[this->heldItemAction]); + Player_SetUpperAction(play, this, sPlayerUpperActionUpdateFuncs[this->heldItemAction]); this->unk_ACC = 0; this->unk_AA4 = 0; - func_8082DCA0(play, this); - this->stateFlags3 &= ~PLAYER_STATE3_40000000; + Player_DetachHeldActor(play, this); + this->stateFlags3 &= ~PLAYER_STATE3_START_CHANGING_HELD_ITEM; } PlayerAnimationHeader* D_8085CFBC[2] = { @@ -3894,7 +3967,7 @@ PlayerAnimationHeader* D_8085CFDC[2] = { PlayerAnimationHeader* func_80830A58(PlayState* play, Player* this) { Player_SetUpperAction(play, this, Player_UpperAction_3); - func_8082DCA0(play, this); + Player_DetachHeldActor(play, this); if (this->unk_B40 < 0.5f) { return D_8085CFBC[Player_IsHoldingTwoHandedWeapon(this)]; @@ -3933,9 +4006,9 @@ s32 func_80830B88(PlayState* play, Player* this) { (this->currentShield != PLAYER_SHIELD_NONE))) && func_8082FBE8(this))) { PlayerAnimationHeader* anim = func_80830A58(play, this); - f32 lastFrame = Animation_GetLastFrame(anim); + f32 endFrame = Animation_GetLastFrame(anim); - PlayerAnimation_Change(play, &this->unk_284, anim, 3.0f / 3.0f, lastFrame, lastFrame, + PlayerAnimation_Change(play, &this->skelAnimeUpper, anim, 3.0f / 3.0f, endFrame, endFrame, ANIMMODE_ONCE, 0.0f); func_80830AE8(this); return true; @@ -3955,26 +4028,28 @@ void func_80830CE8(PlayState* play, Player* this) { func_80123C58(this); } - Animation_Reverse(&this->unk_284); + Animation_Reverse(&this->skelAnimeUpper); func_80830B38(this); } -void func_80830D40(PlayState* play, Player* this) { - struct_8085CC88* entry = &D_8085CC88[this->unk_14E]; - f32 frame = entry->frame; +void Player_WaitToFinishItemChange(PlayState* play, Player* this) { + ItemChangeInfo* itemChangeEntry = &sPlayerItemChangeInfo[this->itemChangeType]; + f32 changeFrame = itemChangeEntry->changeFrame; - if (this->unk_284.playSpeed < 0.0f) { - frame -= 1.0f; + if (this->skelAnimeUpper.playSpeed < 0.0f) { + changeFrame -= 1.0f; } - if (PlayerAnimation_OnFrame(&this->unk_284, frame)) { - func_808308DC(play, this); + + if (PlayerAnimation_OnFrame(&this->skelAnimeUpper, changeFrame)) { + Player_FinishItemChange(play, this); } + func_8082FB68(this); } s32 func_80830DF0(Player* this, PlayState* play) { - if (this->stateFlags3 & PLAYER_STATE3_40000000) { - func_808302CC(this, play); + if (this->stateFlags3 & PLAYER_STATE3_START_CHANGING_HELD_ITEM) { + Player_StartChangingHeldItem(this, play); } else { return false; } @@ -3985,7 +4060,7 @@ s32 func_80830E30(Player* this, PlayState* play) { if ((this->heldItemAction == PLAYER_IA_11) || (this->transformation == PLAYER_FORM_ZORA)) { Player_SetUpperAction(play, this, Player_UpperAction_12); - PlayerAnimation_PlayOnce(play, &this->unk_284, + PlayerAnimation_PlayOnce(play, &this->skelAnimeUpper, (this->meleeWeaponAnimation == PLAYER_MWA_ZORA_PUNCH_LEFT) ? &gPlayerAnim_pz_cutterwaitA : ((this->meleeWeaponAnimation == PLAYER_MWA_ZORA_PUNCH_COMBO) @@ -3997,7 +4072,7 @@ s32 func_80830E30(Player* this, PlayState* play) { return false; } - PlayerAnimation_PlayOnce(play, &this->unk_284, + PlayerAnimation_PlayOnce(play, &this->skelAnimeUpper, (Player_IsHoldingHookshot(this)) ? &gPlayerAnim_link_hook_shot_ready : ((this->transformation == PLAYER_FORM_DEKU) ? &gPlayerAnim_pn_tamahakidf @@ -4036,7 +4111,7 @@ s32 func_80831010(Player* this, PlayState* play) { s32 func_80831094(Player* this, PlayState* play) { if ((this->doorType == PLAYER_DOORTYPE_NONE) && !(this->stateFlags1 & PLAYER_STATE1_2000000)) { - if ((D_80862B48 != 0) || func_80830F9C(play)) { + if (sPlayerUseHeldItem || func_80830F9C(play)) { if (func_80830E30(this, play)) { return func_80831010(this, play); } @@ -4122,7 +4197,7 @@ s32 func_808313A8(PlayState* play, Player* this, Actor* actor) { void func_808313F0(Player* this, PlayState* play) { if (!func_808313A8(play, this, this->heldActor)) { Player_SetUpperAction(play, this, Player_UpperAction_10); - PlayerAnimation_PlayLoop(play, &this->unk_284, &gPlayerAnim_link_normal_carryB_wait); + PlayerAnimation_PlayLoop(play, &this->skelAnimeUpper, &gPlayerAnim_link_normal_carryB_wait); } } @@ -4163,7 +4238,7 @@ s32 Player_SetAction(PlayState* play, Player* this, PlayerActionFunc actionFunc, } } else if ((this->transformation == PLAYER_FORM_GORON) && (Player_GetMeleeWeaponHeld(this) != PLAYER_MELEEWEAPON_NONE)) { - func_80831990(play, this, ITEM_NONE); + Player_UseItem(play, this, ITEM_NONE); } func_800AEF44(Effect_GetByIndex(this->meleeWeaponEffectIndex[2])); @@ -4175,7 +4250,7 @@ s32 Player_SetAction(PlayState* play, Player* this, PlayerActionFunc actionFunc, if (!(arg3 & 1) && !(this->stateFlags1 & PLAYER_STATE1_800)) { func_808309CC(play, this); - PlayerAnimation_PlayLoop(play, &this->unk_284, func_8082ED20(this)); + PlayerAnimation_PlayLoop(play, &this->skelAnimeUpper, func_8082ED20(this)); this->stateFlags1 &= ~PLAYER_STATE1_400000; } @@ -4237,7 +4312,7 @@ void Player_SetAction_PreserveItemAction(PlayState* play, Player* this, PlayerAc } } -void func_808317C4(Player* this) { +void Player_DestroyHookshot(Player* this) { if (Player_IsHoldingHookshot(this)) { if (this->heldActor != NULL) { Actor_Kill(this->heldActor); @@ -4277,13 +4352,12 @@ void func_808318C0(PlayState* play) { // Toggle Lens from a button press void func_80831944(PlayState* play, Player* this) { - if (func_8012364C(play, this, func_8082FDC4()) == ITEM_LENS_OF_TRUTH) { + if (Player_GetItemOnButton(play, this, func_8082FDC4()) == ITEM_LENS_OF_TRUTH) { func_808318C0(play); } } -// Proposed name: Player_UseItem -void func_80831990(PlayState* play, Player* this, ItemId item) { +void Player_UseItem(PlayState* play, Player* this, ItemId item) { PlayerItemAction itemAction = Player_ItemToItemAction(this, item); if ((((this->heldItemAction == this->itemAction) && @@ -4336,15 +4410,20 @@ void func_80831990(PlayState* play, Player* this, ItemId item) { ((explosiveType = Player_ExplosiveFromIA(this, itemAction)) > PLAYER_EXPLOSIVE_NONE) && ((AMMO(sPlayerExplosiveInfo[explosiveType].itemId) == 0) || (play->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].length >= 3)))) { + // Prevent some items from being used if player is out of ammo. + // Also prevent explosives from being used if too many are active Audio_PlaySfx(NA_SE_SY_ERROR); } else if (itemAction == PLAYER_IA_LENS_OF_TRUTH) { + // Handle Lens of Truth func_808318C0(play); } else if (itemAction == PLAYER_IA_PICTOGRAPH_BOX) { + // Handle Pictograph Box if (!func_80831814(this, play, PLAYER_UNKAA5_2)) { Audio_PlaySfx(NA_SE_SY_ERROR); } } else if ((itemAction == PLAYER_IA_DEKU_NUT) && ((this->transformation != PLAYER_FORM_DEKU) || (this->heldItemButton != 0))) { + // Handle Deku Nuts if (AMMO(ITEM_DEKU_NUT) != 0) { func_8083A658(play, this); } else { @@ -4354,6 +4433,7 @@ void func_80831990(PlayState* play, Player* this, ItemId item) { (itemAction < PLAYER_IA_MASK_GIANT)) { PlayerMask maskId = GET_MASK_FROM_IA(itemAction); + // Handle wearable masks this->prevMask = this->currentMask; if (maskId == this->currentMask) { this->currentMask = PLAYER_MASK_NONE; @@ -4367,26 +4447,30 @@ void func_80831990(PlayState* play, Player* this, ItemId item) { ((this->heldActor == NULL) && (Player_ExplosiveFromIA(this, itemAction) > PLAYER_EXPLOSIVE_NONE))) { u8 nextAnimType; + // Handle using a new held item this->nextModelGroup = Player_ActionToModelGroup(this, itemAction); nextAnimType = gPlayerModelTypes[this->nextModelGroup].modelAnimType; var_v1 = ((this->transformation != PLAYER_FORM_GORON) || (itemAction == PLAYER_IA_POWDER_KEG)); if (var_v1 && (this->heldItemAction >= 0) && (item != this->heldItemId) && - (D_8085CD00[gPlayerModelTypes[this->modelGroup].modelAnimType][nextAnimType] != 0)) { + (sPlayerItemChangeTypes[gPlayerModelTypes[this->modelGroup].modelAnimType][nextAnimType] != + PLAYER_ITEM_CHG_0)) { + // Start the held item change process this->heldItemId = item; - this->stateFlags3 |= PLAYER_STATE3_40000000; + this->stateFlags3 |= PLAYER_STATE3_START_CHANGING_HELD_ITEM; } else { - func_808317C4(this); - func_8082DCA0(play, this); - func_8082F470(play, this, itemAction); + // Init new held item for use + Player_DestroyHookshot(this); + Player_DetachHeldActor(play, this); + Player_InitItemActionWithAnim(play, this, itemAction); if (!var_v1) { - D_80862B48 = 1; - D_80862B4C = 1; + sPlayerUseHeldItem = true; + sPlayerHeldItemButtonIsHeldDown = true; } } } else { - D_80862B48 = 1; - D_80862B4C = 1; + sPlayerUseHeldItem = true; + sPlayerHeldItemButtonIsHeldDown = true; } } } @@ -4429,11 +4513,11 @@ void func_80831F34(PlayState* play, Player* this, PlayerAnimationHeader* anim) { } } -s32 func_80832090(Player* this) { +s32 Player_CanUpdateItems(Player* this) { return (!(Player_Action_34 == this->actionFunc) || - (((this->stateFlags3 & PLAYER_STATE3_40000000)) && + ((this->stateFlags3 & PLAYER_STATE3_START_CHANGING_HELD_ITEM) && ((this->heldItemId == ITEM_FC) || (this->heldItemId == ITEM_NONE)))) && - (!(Player_UpperAction_2 == this->upperActionFunc) || + (!(Player_UpperAction_ChangeHeldItem == this->upperActionFunc) || Player_ItemToItemAction(this, this->heldItemId) == this->heldItemAction); } @@ -4442,7 +4526,7 @@ s32 func_8083213C(Player* this) { return (Player_Action_11 == this->actionFunc) || (Player_Action_12 == this->actionFunc); } -s32 func_8083216C(Player* this, PlayState* play) { +s32 Player_UpdateUpperBody(Player* this, PlayState* play) { if (!(this->stateFlags1 & PLAYER_STATE1_800000) && (this->actor.parent != NULL) && Player_IsHoldingHookshot(this)) { Player_SetAction(play, this, Player_Action_92, 1); this->stateFlags3 |= PLAYER_STATE3_80; @@ -4456,8 +4540,8 @@ s32 func_8083216C(Player* this, PlayState* play) { return true; } - if (func_80832090(this)) { - func_808304BC(this, play); + if (Player_CanUpdateItems(this)) { + Player_UpdateItems(this, play); if (Player_Action_64 == this->actionFunc) { return true; } @@ -4467,23 +4551,23 @@ s32 func_8083216C(Player* this, PlayState* play) { return false; } - if (this->unk_AC8 != 0.0f) { + if (this->skelAnimeUpperBlendWeight != 0.0f) { if ((func_8082ED94(this) == 0) || (this->linearVelocity != 0.0f)) { - AnimationContext_SetCopyFalse(play, this->skelAnime.limbCount, this->unk_284.jointTable, - this->skelAnime.jointTable, D_8085B9F0); + AnimationContext_SetCopyFalse(play, this->skelAnime.limbCount, this->skelAnimeUpper.jointTable, + this->skelAnime.jointTable, sPlayerUpperBodyLimbCopyMap); } if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && !(this->skelAnime.moveFlags & ANIM_FLAG_8)) { - Math_StepToF(&this->unk_AC8, 0.0f, 0.25f); + Math_StepToF(&this->skelAnimeUpperBlendWeight, 0.0f, 0.25f); AnimationContext_SetInterp(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->unk_284.jointTable, 1.0f - this->unk_AC8); + this->skelAnimeUpper.jointTable, 1.0f - this->skelAnimeUpperBlendWeight); } } else if ((func_8082ED94(this) == 0) || (this->linearVelocity != 0.0f) || (this->skelAnime.moveFlags & ANIM_FLAG_8)) { AnimationContext_SetCopyTrue(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->unk_284.jointTable, D_8085B9F0); + this->skelAnimeUpper.jointTable, sPlayerUpperBodyLimbCopyMap); } else { AnimationContext_SetCopyAll(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->unk_284.jointTable); + this->skelAnimeUpper.jointTable); } return true; @@ -5014,7 +5098,7 @@ s32 (*sPlayerActionChangeFuncs[PLAYER_ACTION_CHG_MAX])(Player*, PlayState*) = { s32 Player_TryActionChangeList(PlayState* play, Player* this, s8* actionChangeList, s32 updateUpperBody) { if (!(this->stateFlags1 & (PLAYER_STATE1_1 | PLAYER_STATE1_80 | PLAYER_STATE1_20000000)) && !func_8082DA90(play)) { if (updateUpperBody) { - D_80862B04 = func_8083216C(this, play); + D_80862B04 = Player_UpdateUpperBody(this, play); if (Player_Action_64 == this->actionFunc) { return true; } @@ -5025,7 +5109,8 @@ s32 Player_TryActionChangeList(PlayState* play, Player* this, s8* actionChangeLi return true; } - if (!(this->stateFlags3 & PLAYER_STATE3_40000000) && (Player_UpperAction_2 != this->upperActionFunc)) { + if (!(this->stateFlags3 & PLAYER_STATE3_START_CHANGING_HELD_ITEM) && + (Player_UpperAction_ChangeHeldItem != this->upperActionFunc)) { // Process all entries in the Action Change List with a positive index while (*actionChangeList >= 0) { if (sPlayerActionChangeFuncs[*actionChangeList](this, play)) { @@ -5044,7 +5129,7 @@ s32 Player_TryActionChangeList(PlayState* play, Player* this, s8* actionChangeLi return true; } } else if (this->stateFlags1 & PLAYER_STATE1_800) { - func_8083216C(this, play); + Player_UpdateUpperBody(this, play); } return false; @@ -5692,7 +5777,7 @@ s32 func_80834600(Player* this, PlayState* play) { Player_SetUpperAction(play, this, Player_UpperAction_4); var_a2 = (this->unk_B40 < 0.5f) ? D_8085CFD4[Player_IsHoldingTwoHandedWeapon(this)] : D_8085CFCC[Player_IsHoldingTwoHandedWeapon(this)]; - PlayerAnimation_PlayOnce(play, &this->unk_284, var_a2); + PlayerAnimation_PlayOnce(play, &this->skelAnimeUpper, var_a2); } else { Player_AnimationPlayOnce(play, this, D_8085CFDC[Player_IsHoldingTwoHandedWeapon(this)]); } @@ -7678,7 +7763,7 @@ s32 func_808396B8(PlayState* play, Player* this) { ((Player_GetMeleeWeaponHeld(this) != PLAYER_MELEEWEAPON_NONE) && ((this->transformation != PLAYER_FORM_GORON) || (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) && ((this->transformation != PLAYER_FORM_ZORA) || !(this->stateFlags1 & PLAYER_STATE1_2000000)) && - (D_80862B48 != 0)))) { + sPlayerUseHeldItem))) { return true; } @@ -7782,8 +7867,8 @@ s32 Player_ActionChange_10(Player* this, PlayState* play) { func_80836B3C(play, this, 0.0f); } } else if (!(this->stateFlags1 & PLAYER_STATE1_8000000) && - (Player_GetMeleeWeaponHeld(this) != PLAYER_MELEEWEAPON_NONE) && func_80832090(this) && - (this->transformation != PLAYER_FORM_GORON)) { + (Player_GetMeleeWeaponHeld(this) != PLAYER_MELEEWEAPON_NONE) && + Player_CanUpdateItems(this) && (this->transformation != PLAYER_FORM_GORON)) { func_808395F0(play, this, PLAYER_MWA_JUMPSLASH_START, 5.0f, 5.0f); } else if (!func_80839A84(play, this)) { func_80836B3C(play, this, 0.0f); @@ -7909,7 +7994,7 @@ s32 Player_ActionChange_6(Player* this, PlayState* play) { if ((this->putAwayCountdown == 0) && (this->heldItemAction >= PLAYER_IA_SWORD_KOKIRI) && (this->transformation != PLAYER_FORM_FIERCE_DEITY)) { - func_80831990(play, this, ITEM_NONE); + Player_UseItem(play, this, ITEM_NONE); } else { this->stateFlags2 ^= PLAYER_STATE2_100000; } @@ -7927,7 +8012,7 @@ s32 Player_ActionChange_11(Player* this, PlayState* play) { ((this->transformation == PLAYER_FORM_HUMAN) && (this->currentShield != PLAYER_SHIELD_NONE))) && !func_80123434(this) && (this->lockOnActor == NULL))) { func_8082DC38(this); - func_8082DCA0(play, this); + Player_DetachHeldActor(play, this); if (Player_SetAction(play, this, Player_Action_18, 0)) { this->stateFlags1 |= PLAYER_STATE1_400000; if (this->transformation != PLAYER_FORM_GORON) { @@ -8025,7 +8110,7 @@ struct_8085D200 D_8085D200[] = { }; s32 func_8083A6C0(PlayState* play, Player* this) { - if (D_80862B48 != 0) { + if (sPlayerUseHeldItem) { if (Player_GetBottleHeld(this) > PLAYER_BOTTLE_NONE) { Player_SetAction(play, this, Player_Action_68, 0); if (this->actor.depthInWater > 12.0f) { @@ -8977,7 +9062,7 @@ s32 Player_ActionChange_2(Player* this, PlayState* play) { interactRangeActor->parent = &this->actor; if ((Item_CheckObtainability(giEntry->itemId) == ITEM_NONE) || ((s16)giEntry->objectId == OBJECT_GI_BOMB_2)) { - func_8082DCA0(play, this); + Player_DetachHeldActor(play, this); func_80838830(this, giEntry->objectId); if (!(this->stateFlags2 & PLAYER_STATE2_400) || @@ -9539,7 +9624,7 @@ void Player_ChooseIdleAnim(PlayState* play, Player* this) { s32 animIndex; s32 rand; f32 morphFrames; - s16 lastFrame; + s16 endFrame; if (((this->actor.id != ACTOR_PLAYER) && !(healthIsCritical = (this->actor.colChkInfo.health < 0x64))) || ((this->actor.id == ACTOR_PLAYER) && @@ -9586,7 +9671,7 @@ void Player_ChooseIdleAnim(PlayState* play, Player* this) { } } - lastFrame = Animation_GetLastFrame(anim); + endFrame = Animation_GetLastFrame(anim); if ((this->skelAnime.animation == anim) || (this->skelAnime.animation == &gPlayerAnim_pz_attackAend) || (this->skelAnime.animation == &gPlayerAnim_pz_attackBend) || (this->skelAnime.animation == &gPlayerAnim_pz_attackCend)) { @@ -9595,7 +9680,7 @@ void Player_ChooseIdleAnim(PlayState* play, Player* this) { morphFrames = -6.0f; } - PlayerAnimation_Change(play, &this->skelAnime, anim, (2.0f / 3.0f) * D_8085C3E4, 0.0f, lastFrame, ANIMMODE_ONCE, + PlayerAnimation_Change(play, &this->skelAnime, anim, (2.0f / 3.0f) * D_8085C3E4, 0.0f, endFrame, ANIMMODE_ONCE, morphFrames); } @@ -9884,7 +9969,7 @@ s32 func_8083FCF0(PlayState* play, Player* this, f32 arg2, f32 arg3, f32 arg4) { // Crouch-stabbing s32 func_8083FD80(Player* this, PlayState* play) { if (!Player_IsGoronOrDeku(this) && (Player_GetMeleeWeaponHeld(this) != PLAYER_MELEEWEAPON_NONE) && - (this->transformation != PLAYER_FORM_ZORA) && (D_80862B48 != 0)) { + (this->transformation != PLAYER_FORM_ZORA) && sPlayerUseHeldItem) { //! Calling this function sets the meleeWeaponQuads' damage properties correctly, patching "Power Crouch Stab". func_8083375C(this, PLAYER_MWA_STAB_1H); Player_AnimationPlayOnce(play, this, &gPlayerAnim_link_normal_defense_kiru); @@ -9909,7 +9994,7 @@ void Player_RequestQuakeAndRumble(PlayState* play, Player* this, u16 sfxId) { void func_8083FEF4(PlayState* play, Player* this) { Inventory_ChangeAmmo(ITEM_DEKU_STICK, -1); - func_80831990(play, this, ITEM_NONE); + Player_UseItem(play, this, ITEM_NONE); } s32 func_8083FF30(PlayState* play, Player* this) { @@ -9934,7 +10019,7 @@ s32 func_8083FFEC(PlayState* play, Player* this) { gSaveContext.save.saveInfo.playerData.swordHealth--; if (gSaveContext.save.saveInfo.playerData.swordHealth <= 0) { Item_Give(play, ITEM_SWORD_KOKIRI); - func_80831990(play, this, ITEM_SWORD_KOKIRI); + Player_UseItem(play, this, ITEM_SWORD_KOKIRI); Player_PlaySfx(this, NA_SE_IT_MAJIN_SWORD_BROKEN); if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { Message_StartTextbox(play, 0xF9, NULL); @@ -10377,11 +10462,11 @@ void func_80841358(PlayState* play, Player* this, s32 arg2) { //! @bug OoB read if player is goron, deku or human item = D_8085D2B0[this->transformation]; itemAction = sItemItemActions[item]; - func_808317C4(this); - func_8082DCA0(play, this); + Player_DestroyHookshot(this); + Player_DetachHeldActor(play, this); this->heldItemId = item; this->nextModelGroup = Player_ActionToModelGroup(this, itemAction); - func_8082F8BC(play, this, itemAction); + Player_InitItemAction(play, this, itemAction); func_808309CC(play, this); if (arg2) { Player_PlaySfx(this, NA_SE_IT_SWORD_PICKOUT); @@ -10464,7 +10549,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 500, ICHAIN_STOP), }; -Vec3s D_8085D2C4 = { -57, 3377, 0 }; +Vec3s sPlayerSkeletonBaseTransl = { -57, 3377, 0 }; void Player_InitCommon(Player* this, PlayState* play, FlexSkeletonHeader* skelHeader) { Actor_ProcessInitChain(&this->actor, sInitChain); @@ -10476,11 +10561,11 @@ void Player_InitCommon(Player* this, PlayState* play, FlexSkeletonHeader* skelHe func_808309CC(play, this); SkelAnime_InitPlayer(play, &this->skelAnime, skelHeader, D_8085BE84[PLAYER_ANIMGROUP_0][this->modelAnimType], 1 | 8, this->jointTableBuffer, this->morphTableBuffer, PLAYER_LIMB_MAX); - this->skelAnime.baseTransl = D_8085D2C4; + this->skelAnime.baseTransl = sPlayerSkeletonBaseTransl; - SkelAnime_InitPlayer(play, &this->unk_284, skelHeader, func_8082ED20(this), 1 | 8, this->unk_929, this->unk_9C8, - PLAYER_LIMB_MAX); - this->unk_284.baseTransl = D_8085D2C4; + SkelAnime_InitPlayer(play, &this->skelAnimeUpper, skelHeader, func_8082ED20(this), 1 | 8, + this->jointTableUpperBuffer, this->morphTableUpperBuffer, PLAYER_LIMB_MAX); + this->skelAnimeUpper.baseTransl = sPlayerSkeletonBaseTransl; if (this->transformation == PLAYER_FORM_GORON) { SkelAnime_InitFlex(play, &this->unk_2C8, &gLinkGoronShieldingSkel, &gLinkGoronShieldingAnim, @@ -10636,7 +10721,7 @@ void Player_Init(Actor* thisx, PlayState* play) { this->heldItemAction = PLAYER_IA_NONE; this->heldItemId = ITEM_NONE; - func_80831990(play, this, ITEM_NONE); + Player_UseItem(play, this, ITEM_NONE); Player_SetEquipmentData(play, this); this->prevBoots = this->currentBoots; Player_InitCommon(this, play, gPlayerSkeletons[this->transformation]); @@ -10781,7 +10866,7 @@ void Player_Init(Actor* thisx, PlayState* play) { if (gSaveContext.powderKegTimer != 0) { this->nextModelGroup = Player_ActionToModelGroup(this, PLAYER_IA_POWDER_KEG); this->heldItemId = ITEM_POWDER_KEG; - func_8082F8BC(play, this, PLAYER_IA_POWDER_KEG); + Player_InitItemAction(play, this, PLAYER_IA_POWDER_KEG); func_808313F0(this, play); } else if (gSaveContext.unk_1014 != 0) { func_8082F5FC(this, Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_MM, @@ -11497,7 +11582,7 @@ void func_808442D8(PlayState* play, Player* this) { f32 temp_fv1; if (this->unk_B0C == 0.0f) { - func_80831990(play, this, ITEM_NONE); + Player_UseItem(play, this, ITEM_NONE); return; } @@ -12112,7 +12197,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { D_8085C3E4 = (this->stateFlags1 & PLAYER_STATE1_8000000) ? 0.5f : 1.0f; D_8085C3E8 = 1.0f / D_8085C3E4; - D_80862B48 = D_80862B4C = 0; + sPlayerUseHeldItem = sPlayerHeldItemButtonIsHeldDown = false; var_v1 = Play_InCsMode(play); D_80862B2C = this->currentMask; @@ -12318,7 +12403,7 @@ void Player_Update(Actor* thisx, PlayState* play) { } if ((this->heldActor != NULL) && (this->heldActor->update == NULL)) { - func_8082DCA0(play, this); + Player_DetachHeldActor(play, this); } if ((play->actorCtx.unk268 != 0) && (this == GET_PLAYER(play))) { @@ -12812,7 +12897,7 @@ s32 func_80847880(PlayState* play, Player* this) { func_8082DE50(play, this); Player_SetAction(play, this, Player_Action_81, 0); if (!func_800B7118(this) || Player_IsHoldingHookshot(this)) { - func_80831990(play, this, ITEM_BOW); + Player_UseItem(play, this, ITEM_BOW); } Player_AnimationPlayOnce(play, this, func_8082ED20(this)); this->csMode = PLAYER_CSMODE_NONE; @@ -13198,30 +13283,32 @@ s32 Player_UpperAction_1(Player* this, PlayState* play) { return false; } -s32 Player_UpperAction_2(Player* this, PlayState* play) { - if (PlayerAnimation_Update(play, &this->unk_284) || +s32 Player_UpperAction_ChangeHeldItem(Player* this, PlayState* play) { + if (PlayerAnimation_Update(play, &this->skelAnimeUpper) || ((Player_ItemToItemAction(this, this->heldItemId) == this->heldItemAction) && - (D_80862B48 = D_80862B48 || ((this->modelAnimType != PLAYER_ANIMTYPE_3) && - (this->heldItemAction != PLAYER_IA_DEKU_STICK) && (play->unk_1887C == 0))))) { - Player_SetUpperAction(play, this, D_8085C9F0[this->heldItemAction]); + (sPlayerUseHeldItem = + (sPlayerUseHeldItem || ((this->modelAnimType != PLAYER_ANIMTYPE_3) && + (this->heldItemAction != PLAYER_IA_DEKU_STICK) && (play->unk_1887C == 0)))))) { + Player_SetUpperAction(play, this, sPlayerUpperActionUpdateFuncs[this->heldItemAction]); this->unk_ACC = 0; this->unk_AA4 = 0; - D_80862B4C = D_80862B48; + sPlayerHeldItemButtonIsHeldDown = sPlayerUseHeldItem; return this->upperActionFunc(this, play); } if (func_8082ED94(this) != 0) { - func_80830D40(play, this); + Player_WaitToFinishItemChange(play, this); Player_AnimationPlayOnce(play, this, func_8082ED20(this)); this->unk_AA4 = 0; } else { - func_80830D40(play, this); + Player_WaitToFinishItemChange(play, this); } + return true; } s32 Player_UpperAction_3(Player* this, PlayState* play) { - PlayerAnimation_Update(play, &this->unk_284); + PlayerAnimation_Update(play, &this->skelAnimeUpper); if (!CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_R)) { func_80830CE8(play, this); } else { @@ -13235,13 +13322,13 @@ s32 Player_UpperAction_3(Player* this, PlayState* play) { } s32 Player_UpperAction_4(Player* this, PlayState* play) { - if (PlayerAnimation_Update(play, &this->unk_284)) { + if (PlayerAnimation_Update(play, &this->skelAnimeUpper)) { PlayerAnimationHeader* anim; - f32 lastFrame; + f32 endFrame; anim = func_80830A58(play, this); - lastFrame = Animation_GetLastFrame(anim); - PlayerAnimation_Change(play, &this->unk_284, anim, 1.0f, lastFrame, lastFrame, ANIMMODE_ONCE, 0.0f); + endFrame = Animation_GetLastFrame(anim); + PlayerAnimation_Change(play, &this->skelAnimeUpper, anim, 1.0f, endFrame, endFrame, ANIMMODE_ONCE, 0.0f); } this->stateFlags1 |= PLAYER_STATE1_400000; @@ -13250,11 +13337,10 @@ s32 Player_UpperAction_4(Player* this, PlayState* play) { } s32 Player_UpperAction_5(Player* this, PlayState* play) { - // possibly a case of if ((D_80862B48 = D_80862B4C) || PlayerAnimation_Update(play, &this->unk_284)) - D_80862B48 = D_80862B4C; - if ((D_80862B48 != 0) || PlayerAnimation_Update(play, &this->unk_284)) { - Player_SetUpperAction(play, this, D_8085C9F0[this->heldItemAction]); - PlayerAnimation_PlayLoop(play, &this->unk_284, D_8085BE84[PLAYER_ANIMGROUP_0][this->modelAnimType]); + sPlayerUseHeldItem = sPlayerHeldItemButtonIsHeldDown; + if (sPlayerUseHeldItem || PlayerAnimation_Update(play, &this->skelAnimeUpper)) { + Player_SetUpperAction(play, this, sPlayerUpperActionUpdateFuncs[this->heldItemAction]); + PlayerAnimation_PlayLoop(play, &this->skelAnimeUpper, D_8085BE84[PLAYER_ANIMGROUP_0][this->modelAnimType]); this->unk_AA4 = 0; this->upperActionFunc(this, play); return false; @@ -13312,10 +13398,10 @@ s32 Player_UpperAction_7(Player* this, PlayState* play) { if ((this->unk_ACE == 0) && (func_8082ED94(this) == 0) && (this->skelAnime.animation == &gPlayerAnim_link_bow_side_walk)) { - PlayerAnimation_PlayOnce(play, &this->unk_284, D_8085D5E4[index]); + PlayerAnimation_PlayOnce(play, &this->skelAnimeUpper, D_8085D5E4[index]); this->unk_ACE = -1; - } else if (PlayerAnimation_Update(play, &this->unk_284)) { - PlayerAnimation_PlayLoop(play, &this->unk_284, D_8085D5F0[index]); + } else if (PlayerAnimation_Update(play, &this->skelAnimeUpper)) { + PlayerAnimation_PlayLoop(play, &this->skelAnimeUpper, D_8085D5F0[index]); this->unk_ACE = 1; } else if (this->unk_ACE == 1) { this->unk_ACE = 2; @@ -13326,7 +13412,7 @@ s32 Player_UpperAction_7(Player* this, PlayState* play) { } func_80831010(this, play); - if ((this->unk_ACE > 0) && ((this->unk_B28 < 0) || ((D_80862B4C == 0) && !func_80830FD4(play)))) { + if ((this->unk_ACE > 0) && ((this->unk_B28 < 0) || (!sPlayerHeldItemButtonIsHeldDown && !func_80830FD4(play)))) { Player_SetUpperAction(play, this, Player_UpperAction_8); if (this->unk_B28 >= 0) { if (index != 0) { @@ -13335,7 +13421,8 @@ s32 Player_UpperAction_7(Player* this, PlayState* play) { } if (this->transformation == PLAYER_FORM_DEKU) { - PlayerAnimation_PlayOnceSetSpeed(play, &this->unk_284, &gPlayerAnim_pn_tamahaki, 2.0f / 3.0f); + PlayerAnimation_PlayOnceSetSpeed(play, &this->skelAnimeUpper, &gPlayerAnim_pn_tamahaki, + 2.0f / 3.0f); } } else if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { func_80831194(play, this); @@ -13351,15 +13438,15 @@ s32 Player_UpperAction_7(Player* this, PlayState* play) { } s32 Player_UpperAction_8(Player* this, PlayState* play) { - s32 animFinished = PlayerAnimation_Update(play, &this->unk_284); + s32 animFinished = PlayerAnimation_Update(play, &this->skelAnimeUpper); if (Player_IsHoldingHookshot(this) && !func_80831124(play, this)) { return true; } if (!func_80830B88(play, this) && - ((((this->unk_B28 < 0) && (D_80862B4C != 0)) || - ((animFinished || (this->transformation != PLAYER_FORM_DEKU)) && (D_80862B48 != 0))) || + ((((this->unk_B28 < 0) && sPlayerHeldItemButtonIsHeldDown) || + ((animFinished || (this->transformation != PLAYER_FORM_DEKU)) && sPlayerUseHeldItem)) || func_80830F9C(play))) { this->unk_B28 = ABS_ALT(this->unk_B28); @@ -13367,7 +13454,7 @@ s32 Player_UpperAction_8(Player* this, PlayState* play) { if (Player_IsHoldingHookshot(this)) { this->unk_ACE = 1; } else { - PlayerAnimation_PlayOnce(play, &this->unk_284, + PlayerAnimation_PlayOnce(play, &this->skelAnimeUpper, (this->transformation == PLAYER_FORM_DEKU) ? &gPlayerAnim_pn_tamahakidf : &gPlayerAnim_link_bow_bow_shoot_next); @@ -13389,7 +13476,7 @@ s32 Player_UpperAction_8(Player* this, PlayState* play) { Player_SetUpperAction(play, this, Player_UpperAction_6); } else { Player_SetUpperAction(play, this, Player_UpperAction_9); - PlayerAnimation_PlayOnce(play, &this->unk_284, + PlayerAnimation_PlayOnce(play, &this->skelAnimeUpper, (this->transformation == PLAYER_FORM_DEKU) ? &gPlayerAnim_pn_tamahakidf : &gPlayerAnim_link_bow_bow_shoot_end); } @@ -13400,7 +13487,7 @@ s32 Player_UpperAction_8(Player* this, PlayState* play) { } s32 Player_UpperAction_9(Player* this, PlayState* play) { - if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || PlayerAnimation_Update(play, &this->unk_284)) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || PlayerAnimation_Update(play, &this->skelAnimeUpper)) { Player_SetUpperAction(play, this, Player_UpperAction_6); } return true; @@ -13418,8 +13505,8 @@ s32 Player_UpperAction_10(Player* this, PlayState* play) { } if (this->stateFlags1 & PLAYER_STATE1_800) { - if (PlayerAnimation_Update(play, &this->unk_284)) { - PlayerAnimation_PlayLoop(play, &this->unk_284, &gPlayerAnim_link_normal_carryB_wait); + if (PlayerAnimation_Update(play, &this->skelAnimeUpper)) { + PlayerAnimation_PlayLoop(play, &this->skelAnimeUpper, &gPlayerAnim_link_normal_carryB_wait); } if ((heldActor->id == ACTOR_EN_NIW) && (this->actor.velocity.y <= 0.0f)) { @@ -13447,31 +13534,31 @@ s32 Player_UpperAction_11(Player* this, PlayState* play) { } s32 Player_UpperAction_12(Player* this, PlayState* play) { - if (PlayerAnimation_Update(play, &this->unk_284)) { + if (PlayerAnimation_Update(play, &this->skelAnimeUpper)) { Player_SetUpperAction(play, this, Player_UpperAction_13); - PlayerAnimation_PlayLoop(play, &this->unk_284, &gPlayerAnim_pz_cutterwaitanim); + PlayerAnimation_PlayLoop(play, &this->skelAnimeUpper, &gPlayerAnim_pz_cutterwaitanim); } - if (this->unk_284.animation == &gPlayerAnim_pz_cutterwaitanim) { + if (this->skelAnimeUpper.animation == &gPlayerAnim_pz_cutterwaitanim) { func_80831010(this, play); } return true; } s32 Player_UpperAction_13(Player* this, PlayState* play) { - PlayerAnimation_Update(play, &this->unk_284); + PlayerAnimation_Update(play, &this->skelAnimeUpper); func_80831010(this, play); - if (D_80862B4C == 0) { + if (!sPlayerHeldItemButtonIsHeldDown) { Player_SetUpperAction(play, this, Player_UpperAction_14); - PlayerAnimation_PlayOnce(play, &this->unk_284, &gPlayerAnim_pz_cutterattack); + PlayerAnimation_PlayOnce(play, &this->skelAnimeUpper, &gPlayerAnim_pz_cutterattack); } return true; } s32 Player_UpperAction_14(Player* this, PlayState* play) { - if (PlayerAnimation_Update(play, &this->unk_284)) { + if (PlayerAnimation_Update(play, &this->skelAnimeUpper)) { Player_SetUpperAction(play, this, Player_UpperAction_15); this->unk_ACC = 0; - } else if (PlayerAnimation_OnFrame(&this->unk_284, 6.0f)) { + } else if (PlayerAnimation_OnFrame(&this->skelAnimeUpper, 6.0f)) { Vec3f pos; s16 untargetedRotY; @@ -13535,7 +13622,7 @@ s32 Player_UpperAction_15(Player* this, PlayState* play) { if (this->stateFlags3 & PLAYER_STATE3_800000) { Player_SetUpperAction(play, this, Player_UpperAction_16); - PlayerAnimation_PlayOnce(play, &this->unk_284, &gPlayerAnim_pz_cuttercatch); + PlayerAnimation_PlayOnce(play, &this->skelAnimeUpper, &gPlayerAnim_pz_cuttercatch); this->stateFlags3 &= ~PLAYER_STATE3_800000; Player_PlaySfx(this, NA_SE_PL_CATCH_BOOMERANG); Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_SWORD_N); @@ -13546,7 +13633,7 @@ s32 Player_UpperAction_15(Player* this, PlayState* play) { } s32 Player_UpperAction_16(Player* this, PlayState* play) { - if (!Player_UpperAction_11(this, play) && PlayerAnimation_Update(play, &this->unk_284)) { + if (!Player_UpperAction_11(this, play) && PlayerAnimation_Update(play, &this->skelAnimeUpper)) { if (this->stateFlags1 & PLAYER_STATE1_2000000) { Player_SetUpperAction(play, this, Player_UpperAction_15); this->unk_ACC = 0; @@ -13579,7 +13666,7 @@ void Player_Action_0(Player* this, PlayState* play) { void Player_Action_1(Player* this, PlayState* play) { this->stateFlags3 |= PLAYER_STATE3_10000000; PlayerAnimation_Update(play, &this->skelAnime); - func_8083216C(this, play); + Player_UpdateUpperBody(this, play); if (R_PLAY_FILL_SCREEN_ON == 0) { R_PLAY_FILL_SCREEN_ON = 20; @@ -14047,7 +14134,7 @@ void Player_Action_10(Player* this, PlayState* play) { AnimationContext_SetLoadFrame(play, func_8082ED20(this), 0, this->skelAnime.limbCount, this->skelAnime.morphTable); AnimationContext_SetCopyTrue(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->skelAnime.morphTable, D_8085B9F0); + this->skelAnime.morphTable, sPlayerUpperBodyLimbCopyMap); } Player_GetMovementSpeedAndYaw(this, &speedTarget, &yawTarget, SPEED_MODE_CURVED, play); @@ -14294,7 +14381,7 @@ void Player_Action_18(Player* this, PlayState* play) { if (!Player_IsGoronOrDeku(this)) { this->stateFlags1 |= PLAYER_STATE1_400000; - func_8083216C(this, play); + Player_UpdateUpperBody(this, play); this->stateFlags1 &= ~PLAYER_STATE1_400000; if (this->transformation == PLAYER_FORM_ZORA) { func_8082F164(this, BTN_R | BTN_B); @@ -14368,8 +14455,9 @@ void Player_Action_18(Player* this, PlayState* play) { void Player_Action_19(Player* this, PlayState* play) { func_80832F24(this); if (this->actionVar1 == 0) { - D_80862B04 = func_8083216C(this, play); - if ((Player_UpperAction_3 == this->upperActionFunc) || (func_808331FC(play, this, &this->unk_284, 4.0f) > 0)) { + D_80862B04 = Player_UpdateUpperBody(this, play); + if ((Player_UpperAction_3 == this->upperActionFunc) || + (func_808331FC(play, this, &this->skelAnimeUpper, 4.0f) > 0)) { Player_SetAction(play, this, Player_Action_2, 1); } } else { @@ -14379,13 +14467,13 @@ void Player_Action_19(Player* this, PlayState* play) { temp_v0 = func_808331FC(play, this, &this->skelAnime, 4.0f); if ((temp_v0 != 0) && ((temp_v0 > 0) || PlayerAnimation_Update(play, &this->skelAnime))) { PlayerAnimationHeader* anim; - f32 lastFrame; + f32 endFrame; Player_SetAction(play, this, Player_Action_18, 1); Player_SetModelsForHoldingShield(this); anim = D_8085BE84[PLAYER_ANIMGROUP_19][this->modelAnimType]; - lastFrame = Animation_GetLastFrame(anim); - PlayerAnimation_Change(play, &this->skelAnime, anim, 1.0f, lastFrame, lastFrame, ANIMMODE_ONCE, 0.0f); + endFrame = Animation_GetLastFrame(anim); + PlayerAnimation_Change(play, &this->skelAnime, anim, 1.0f, endFrame, endFrame, ANIMMODE_ONCE, 0.0f); } } } @@ -14575,7 +14663,7 @@ void Player_Action_25(Player* this, PlayState* play) { func_8083CBC4(this, speedTarget, yawTarget, 1.0f, 0.05f, 0.1f, 0xC8); } - func_8083216C(this, play); + Player_UpdateUpperBody(this, play); if ((((this->stateFlags2 & PLAYER_STATE2_80000) && ((this->actionVar1 == 2) || (this->actionVar1 >= 4))) || !func_80839770(this, play)) && (this->actor.velocity.y < 0.0f)) { @@ -14631,7 +14719,7 @@ void Player_Action_25(Player* this, PlayState* play) { } } else { func_80837134(play, this); - func_8083216C(this, play); + Player_UpdateUpperBody(this, play); } Player_ActionChange_13(this, play); @@ -15013,9 +15101,9 @@ void Player_Action_34(Player* this, PlayState* play) { PlayerAnimation_Update(play, &this->skelAnime); func_8083249C(this); - temp_v0 = func_8083216C(this, play); + temp_v0 = Player_UpdateUpperBody(this, play); if (((this->stateFlags1 & PLAYER_STATE1_800) && (this->heldActor != NULL) && (this->getItemId == GI_NONE)) || - (temp_v0 == 0)) { + !temp_v0) { this->unk_D58(play, this); } } @@ -15183,7 +15271,7 @@ void Player_Action_35(Player* this, PlayState* play) { } if (this->stateFlags1 & PLAYER_STATE1_800) { - func_8083216C(this, play); + Player_UpdateUpperBody(this, play); } } @@ -15202,7 +15290,7 @@ void Player_Action_36(Player* this, PlayState* play) { } animFinished = PlayerAnimation_Update(play, &this->skelAnime); - func_8083216C(this, play); + Player_UpdateUpperBody(this, play); if (animFinished) { if (this->actionVar2 == 0) { @@ -15359,7 +15447,7 @@ void Player_Action_43(Player* this, PlayState* play) { if (this->unk_AA5 == PLAYER_UNKAA5_3) { if (func_800B7118(this) || func_8082ECCC(this)) { - func_8083216C(this, play); + Player_UpdateUpperBody(this, play); } } @@ -15394,7 +15482,7 @@ void Player_Action_44(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_20; func_8083249C(this); - func_8083216C(this, play); + Player_UpdateUpperBody(this, play); if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { this->actor.flags &= ~ACTOR_FLAG_TALK_REQUESTED; if (!CHECK_FLAG_ALL(this->talkActor->flags, ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_UNFRIENDLY)) { @@ -15447,24 +15535,24 @@ void Player_Action_44(Player* this, PlayState* play) { this->actor.shape.rot.y = this->currentYaw; if (this->actionVar1 != 0) { if (!(this->stateFlags1 & PLAYER_STATE1_800)) { - if (PlayerAnimation_Update(play, &this->unk_284)) { + if (PlayerAnimation_Update(play, &this->skelAnimeUpper)) { this->actionVar1--; if (this->actionVar1 != 0) { - PlayerAnimation_Change(play, &this->unk_284, &gPlayerAnim_link_normal_talk_free, 1.0f, 0.0f, - Animation_GetLastFrame(&gPlayerAnim_link_normal_talk_free), + PlayerAnimation_Change(play, &this->skelAnimeUpper, &gPlayerAnim_link_normal_talk_free, 1.0f, + 0.0f, Animation_GetLastFrame(&gPlayerAnim_link_normal_talk_free), ANIMMODE_ONCE, -6.0f); } } } AnimationContext_SetCopyFalse(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->unk_284.jointTable, D_8085B9F0); + this->skelAnimeUpper.jointTable, sPlayerUpperBodyLimbCopyMap); } else if (!(this->stateFlags1 & PLAYER_STATE1_800) && (this->skelAnime.animation == &gPlayerAnim_link_normal_talk_free_wait)) { s32 temp_v0 = this->actor.focus.rot.y - this->actor.shape.rot.y; if (ABS_ALT(temp_v0) > 0xFA0) { PlayerAnimation_Change( - play, &this->unk_284, D_8085BE84[PLAYER_ANIMGROUP_25][this->modelAnimType], 0.4f, 0.0f, + play, &this->skelAnimeUpper, D_8085BE84[PLAYER_ANIMGROUP_25][this->modelAnimType], 0.4f, 0.0f, Animation_GetLastFrame(D_8085BE84[PLAYER_ANIMGROUP_25][this->modelAnimType]), ANIMMODE_ONCE, -6.0f); this->actionVar1 = 2; } @@ -16001,7 +16089,7 @@ void Player_Action_52(Player* this, PlayState* play) { this->unk_AA5 = PLAYER_UNKAA5_0; this->actionVar1 = 0; } else if ((this->actionVar2 < 2) || (this->actionVar2 >= 4)) { - D_80862B04 = func_8083216C(this, play); + D_80862B04 = Player_UpdateUpperBody(this, play); if (D_80862B04) { this->actionVar1 = 0; } @@ -16015,27 +16103,27 @@ void Player_Action_52(Player* this, PlayState* play) { if (!D_80862B04) { if (this->actionVar1 != 0) { - if (PlayerAnimation_Update(play, &this->unk_284)) { + if (PlayerAnimation_Update(play, &this->skelAnimeUpper)) { rideActor->stateFlags &= ~ENHORSE_FLAG_8; this->actionVar1 = 0; } - if (this->unk_284.animation == &gPlayerAnim_link_uma_stop_muti) { - if (PlayerAnimation_OnFrame(&this->unk_284, 23.0f)) { + if (this->skelAnimeUpper.animation == &gPlayerAnim_link_uma_stop_muti) { + if (PlayerAnimation_OnFrame(&this->skelAnimeUpper, 23.0f)) { Player_PlaySfx(this, NA_SE_IT_LASH); Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_LASH); } AnimationContext_SetCopyAll(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->unk_284.jointTable); + this->skelAnimeUpper.jointTable); } else { - if (PlayerAnimation_OnFrame(&this->unk_284, 10.0f)) { + if (PlayerAnimation_OnFrame(&this->skelAnimeUpper, 10.0f)) { Player_PlaySfx(this, NA_SE_IT_LASH); Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_LASH); } AnimationContext_SetCopyTrue(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->unk_284.jointTable, D_8085B9F0); + this->skelAnimeUpper.jointTable, sPlayerUpperBodyLimbCopyMap); } } else if (!CHECK_FLAG_ALL(this->actor.flags, 0x100)) { PlayerAnimationHeader* anim = NULL; @@ -16049,7 +16137,7 @@ void Player_Action_52(Player* this, PlayState* play) { } if (anim != NULL) { - PlayerAnimation_PlayOnce(play, &this->unk_284, anim); + PlayerAnimation_PlayOnce(play, &this->skelAnimeUpper, anim); this->actionVar1 = 1; } } @@ -16439,7 +16527,7 @@ void Player_Action_59(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_20; this->actor.gravity = 0.0f; - func_8083216C(this, play); + Player_UpdateUpperBody(this, play); func_8082F164(this, BTN_R); if (Player_ActionChange_13(this, play)) { @@ -17149,7 +17237,7 @@ void Player_Action_68(Player* this, PlayState* play) { Player_PlaySfx(this, NA_SE_IT_SCOOP_UP_WATER); } - if (func_8012364C(play, this, this->heldItemButton) == ITEM_BOTTLE) { + if (Player_GetItemOnButton(play, this, this->heldItemButton) == ITEM_BOTTLE) { Actor* interactRangeActor = this->interactRangeActor; if (interactRangeActor != NULL) { @@ -17531,7 +17619,7 @@ void Player_Action_80(Player* this, PlayState* play) { } else { this->stateFlags1 &= ~PLAYER_STATE1_100000; if ((play->sceneId == SCENE_20SICHITAI) && - (func_8012364C(play, this, func_8082FDC4()) == ITEM_PICTOGRAPH_BOX)) { + (Player_GetItemOnButton(play, this, func_8082FDC4()) == ITEM_PICTOGRAPH_BOX)) { s32 requiredScopeTemp; play->actorCtx.flags |= ACTORCTX_FLAG_PICTO_BOX_ON; @@ -17554,7 +17642,7 @@ void Player_Action_81(Player* this, PlayState* play) { this->unk_AA5 = PLAYER_UNKAA5_3; func_8083868C(play, this); PlayerAnimation_Update(play, &this->skelAnime); - func_8083216C(this, play); + Player_UpdateUpperBody(this, play); this->upperLimbRot.y = func_80847190(play, this, 1) - this->actor.shape.rot.y; this->unk_AA6 |= 0x80; @@ -17651,7 +17739,7 @@ void Player_Action_84(Player* this, PlayState* play) { ((this->meleeWeaponAnimation >= PLAYER_MWA_FLIPSLASH_FINISH) && (this->meleeWeaponAnimation <= PLAYER_MWA_ZORA_JUMPKICK_FINISH) && (this->skelAnime.curFrame > 2.0f) && func_808333CC(this))) { - D_80862B48 = this->actionVar2; + sPlayerUseHeldItem = this->actionVar2; if (!Player_ActionChange_7(this, play)) { PlayerAnimationHeader* anim = func_80123420(this) ? attackInfoEntry->unk_8 : attackInfoEntry->unk_4; @@ -17666,7 +17754,7 @@ void Player_Action_84(Player* this, PlayState* play) { if (this->transformation == PLAYER_FORM_ZORA) { if (Player_ActionChange_8(this, play)) { - anim = this->unk_284.animation; + anim = this->skelAnimeUpper.animation; } this->unk_ADC = 0; } else if ((anim == &gPlayerAnim_link_fighter_Lpower_jump_kiru_end) && @@ -19670,7 +19758,7 @@ void Player_CsAction_0(PlayState* play, Player* this, CsCmdActorCue* cue) { } else { PlayerAnimation_Update(play, &this->skelAnime); if (func_801240DC(this) || (this->stateFlags1 & PLAYER_STATE1_800)) { - func_8083216C(this, play); + Player_UpdateUpperBody(this, play); } else if ((this->interactRangeActor != NULL) && (this->interactRangeActor->textId == 0xFFFF)) { Player_ActionChange_2(this, play); } @@ -19707,7 +19795,7 @@ void Player_CsAction_2(PlayState* play, Player* this, CsCmdActorCue* cue) { } else { PlayerAnimation_Update(play, &this->skelAnime); if (func_801240DC(this) || (this->stateFlags1 & PLAYER_STATE1_800)) { - func_8083216C(this, play); + Player_UpdateUpperBody(this, play); } } } @@ -20232,7 +20320,7 @@ void func_8085AC9C(PlayState* play, Player* this, CsCmdActorCue* cue, PlayerCsMo void func_8085AD5C(PlayState* play, Player* this, PlayerCsMode csMode) { if ((csMode != PLAYER_CSMODE_1) && (csMode != PLAYER_CSMODE_WAIT) && (csMode != PLAYER_CSMODE_20) && (csMode != PLAYER_CSMODE_END)) { - func_8082DCA0(play, this); + Player_DetachHeldActor(play, this); } } @@ -20326,7 +20414,7 @@ s32 Player_StartFishing(PlayState* play) { Player* player = GET_PLAYER(play); func_8082DE50(play, player); - func_80831990(play, player, ITEM_FISHING_ROD); + Player_UseItem(play, player, ITEM_FISHING_ROD); return 1; } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 0ecbdb9b1..83c871191 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2199,7 +2199,7 @@ 0x801234D4:("func_801234D4",), 0x80123590:("func_80123590",), 0x801235DC:("func_801235DC",), - 0x8012364C:("func_8012364C",), + 0x8012364C:("Player_GetItemOnButton",), 0x80123810:("func_80123810",), 0x80123960:("Player_ActionToModelGroup",), 0x801239AC:("Player_SetModelsForHoldingShield",), @@ -4256,7 +4256,7 @@ 0x8082DC28:("func_8082DC28",), 0x8082DC38:("func_8082DC38",), 0x8082DC64:("func_8082DC64",), - 0x8082DCA0:("func_8082DCA0",), + 0x8082DCA0:("Player_DetachHeldActor",), 0x8082DD2C:("func_8082DD2C",), 0x8082DE14:("func_8082DE14",), 0x8082DE50:("func_8082DE50",), @@ -4314,7 +4314,7 @@ 0x8082F164:("func_8082F164",), 0x8082F1AC:("func_8082F1AC",), 0x8082F43C:("Player_SetUpperAction",), - 0x8082F470:("func_8082F470",), + 0x8082F470:("Player_InitItemActionWithAnim",), 0x8082F524:("Player_ItemToItemAction",), 0x8082F594:("Player_InitItemAction_DoNothing",), 0x8082F5A4:("Player_InitItemAction_DekuStick",), @@ -4323,30 +4323,30 @@ 0x8082F62C:("Player_InitItemAction_SpawnExplosive",), 0x8082F7F4:("Player_InitItemAction_SpawnHookshot",), 0x8082F8A0:("Player_InitItemAction_5",), - 0x8082F8BC:("func_8082F8BC",), + 0x8082F8BC:("Player_InitItemAction",), 0x8082F938:("Player_OverrideBlureColors",), 0x8082FA5C:("func_8082FA5C",), 0x8082FB68:("func_8082FB68",), 0x8082FBE8:("func_8082FBE8",), 0x8082FC24:("func_8082FC24",), 0x8082FC60:("func_8082FC60",), - 0x8082FC78:("func_8082FC78",), - 0x8082FCC4:("func_8082FCC4",), + 0x8082FC78:("Player_ItemIsInUse",), + 0x8082FCC4:("Player_ItemIsItemAction",), 0x8082FD0C:("func_8082FD0C",), 0x8082FDC4:("func_8082FDC4",), - 0x8082FE0C:("func_8082FE0C",), - 0x808302CC:("func_808302CC",), - 0x808304BC:("func_808304BC",), + 0x8082FE0C:("Player_ProcessItemButtons",), + 0x808302CC:("Player_StartChangingHeldItem",), + 0x808304BC:("Player_UpdateItems",), 0x808305BC:("func_808305BC",), 0x808306F8:("func_808306F8",), - 0x808308DC:("func_808308DC",), + 0x808308DC:("Player_FinishItemChange",), 0x808309CC:("func_808309CC",), 0x80830A58:("func_80830A58",), 0x80830AE8:("func_80830AE8",), 0x80830B38:("func_80830B38",), 0x80830B88:("func_80830B88",), 0x80830CE8:("func_80830CE8",), - 0x80830D40:("func_80830D40",), + 0x80830D40:("Player_WaitToFinishItemChange",), 0x80830DF0:("func_80830DF0",), 0x80830E30:("func_80830E30",), 0x80830F9C:("func_80830F9C",), @@ -4362,15 +4362,15 @@ 0x80831494:("Player_SetAction",), 0x8083172C:("Player_SetAction_PreserveMoveFlags",), 0x80831760:("Player_SetAction_PreserveItemAction",), - 0x808317C4:("func_808317C4",), + 0x808317C4:("Player_DestroyHookshot",), 0x80831814:("func_80831814",), 0x808318C0:("func_808318C0",), 0x80831944:("func_80831944",), - 0x80831990:("func_80831990",), + 0x80831990:("Player_UseItem",), 0x80831F34:("func_80831F34",), - 0x80832090:("func_80832090",), + 0x80832090:("Player_CanUpdateItems",), 0x8083213C:("func_8083213C",), - 0x8083216C:("func_8083216C",), + 0x8083216C:("Player_UpdateUpperBody",), 0x808323C0:("func_808323C0",), 0x80832444:("func_80832444",), 0x8083249C:("func_8083249C",), @@ -4646,7 +4646,7 @@ 0x80848640:("func_80848640",), 0x80848780:("Player_UpperAction_0",), 0x808487B8:("Player_UpperAction_1",), - 0x80848808:("Player_UpperAction_2",), + 0x80848808:("Player_UpperAction_ChangeHeldItem",), 0x8084894C:("Player_UpperAction_3",), 0x80848A0C:("Player_UpperAction_4",), 0x80848AB0:("Player_UpperAction_5",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 9320ca10e..aababcf0b 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4914,7 +4914,7 @@ 0x8082DA82:("sPauseZRCursorGreen","UNK_TYPE1","",0x1), 0x8082DA84:("sPauseZRCursorBlue","UNK_TYPE1","",0x1), 0x8082DA86:("sPauseZRCursorAlpha","UNK_TYPE1","",0x1), - 0x8085B9F0:("D_8085B9F0","UNK_TYPE1","",0x1), + 0x8085B9F0:("sPlayerUpperBodyLimbCopyMap","UNK_TYPE1","",0x1), 0x8085BA08:("D_8085BA08","UNK_TYPE1","",0x1), 0x8085BA20:("D_8085BA20","UNK_TYPE1","",0x1), 0x8085BA38:("sPlayerAgeProperties","UNK_TYPE1","",0x1), @@ -4944,10 +4944,10 @@ 0x8085C96C:("D_8085C96C","UNK_TYPE1","",0x1), 0x8085C98C:("sZoraBarrierEnvLighting","UNK_TYPE1","",0x1), 0x8085C99C:("sItemActionParams","UNK_TYPE1","",0x1), - 0x8085C9F0:("D_8085C9F0","UNK_PTR","",0x4), - 0x8085CB3C:("sPlayerInitItemActionFuncs","UNK_PTR","",0x4), - 0x8085CC88:("D_8085CC88","UNK_TYPE1","",0x1), - 0x8085CD00:("D_8085CD00","s8","[36]",0x24), + 0x8085C9F0:("sPlayerUpperActionUpdateFuncs","UNK_PTR","",0x4), + 0x8085CB3C:("sPlayerItemActionInitFuncs","UNK_PTR","",0x4), + 0x8085CC88:("sPlayerItemChangeInfo","UNK_TYPE1","",0x1), + 0x8085CD00:("sPlayerItemChangeTypes","s8","[36]",0x24), 0x8085CD24:("sPlayerExplosiveInfo","UNK_TYPE1","",0x1), 0x8085CD30:("sMeleeAttackAnimInfo","UNK_TYPE1","",0x220), 0x8085CF50:("D_8085CF50","UNK_TYPE1","",0x1), @@ -4959,7 +4959,7 @@ 0x8085CF80:("D_8085CF80","UNK_TYPE1","",0x1), 0x8085CF84:("D_8085CF84","UNK_TYPE1","",0x1), 0x8085CF88:("D_8085CF88","BlureColors","[2]",0x20), - 0x8085CFA8:("D_8085CFA8","u16","[4]",0x8), + 0x8085CFA8:("sPlayerItemButtons","u16","[4]",0x8), 0x8085CFB0:("D_8085CFB0","UNK_TYPE1","",0x1), 0x8085CFB8:("sMagicArrowCosts","u8","[4]",0x4), 0x8085CFBC:("D_8085CFBC","UNK_TYPE1","",0x1), @@ -5017,7 +5017,7 @@ 0x8085D2B0:("D_8085D2B0","UNK_TYPE1","",0x1), 0x8085D2B4:("D_8085D2B4","UNK_TYPE1","",0x1), 0x8085D2C0:("sInitChain","ActorInitVar","",0x4), - 0x8085D2C4:("D_8085D2C4","UNK_TYPE4","",0x4), + 0x8085D2C4:("sPlayerSkeletonBaseTransl","UNK_TYPE4","",0x4), 0x8085D2CC:("D_8085D2CC","UNK_PTR","",0x4), 0x8085D30C:("D_8085D30C","EffectBlureInit2","",0x24), 0x8085D330:("D_8085D330","EffectTireMarkInit","",0x8), @@ -5377,8 +5377,8 @@ 0x80862B3C:("D_80862B3C","f32","",0x4), 0x80862B40:("sPlayerFloorEffect","UNK_TYPE1","",0x1), 0x80862B44:("sPlayerControlInput","UNK_TYPE1","",0x1), - 0x80862B48:("D_80862B48","UNK_TYPE1","",0x1), - 0x80862B4C:("D_80862B4C","UNK_TYPE1","",0x1), + 0x80862B48:("sPlayerUseHeldItem","UNK_TYPE1","",0x1), + 0x80862B4C:("sPlayerHeldItemButtonIsHeldDown","UNK_TYPE1","",0x1), 0x80862B50:("D_80862B50","UNK_TYPE1","",0x1), 0x80862B6C:("D_80862B6C","UNK_TYPE1","",0x1), 0x808637B0:("En_Test_InitVars","ActorInit","",0x20), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index caaa33d73..5194497c7 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1713,7 +1713,7 @@ asm/non_matchings/code/z_player_lib/Player_IsGoronOrDeku.s,Player_IsGoronOrDeku, asm/non_matchings/code/z_player_lib/func_801234D4.s,func_801234D4,0x801234D4,0x2F asm/non_matchings/code/z_player_lib/func_80123590.s,func_80123590,0x80123590,0x13 asm/non_matchings/code/z_player_lib/func_801235DC.s,func_801235DC,0x801235DC,0x1C -asm/non_matchings/code/z_player_lib/func_8012364C.s,func_8012364C,0x8012364C,0x71 +asm/non_matchings/code/z_player_lib/Player_GetItemOnButton.s,Player_GetItemOnButton,0x8012364C,0x71 asm/non_matchings/code/z_player_lib/func_80123810.s,func_80123810,0x80123810,0x54 asm/non_matchings/code/z_player_lib/Player_ActionToModelGroup.s,Player_ActionToModelGroup,0x80123960,0x13 asm/non_matchings/code/z_player_lib/Player_SetModelsForHoldingShield.s,Player_SetModelsForHoldingShield,0x801239AC,0x3E From 1509349bd76a90e163a538fb159bffa74a54f8a9 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Sun, 1 Oct 2023 12:56:38 +1100 Subject: [PATCH 8/9] Animation Cleanup: En_K* (#1402) * cleanup k * one more name --- src/code/z_skelanime.c | 3 +- .../actors/ovl_En_Fishing/z_en_fishing.c | 5 +- .../ovl_En_Guard_Nuts/z_en_guard_nuts.c | 3 +- .../actors/ovl_En_Kaizoku/z_en_kaizoku.c | 50 +++-- .../actors/ovl_En_Kaizoku/z_en_kaizoku.h | 2 +- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 40 ++-- src/overlays/actors/ovl_En_Kame/z_en_kame.c | 6 +- src/overlays/actors/ovl_En_Kbt/z_en_kbt.c | 151 +++++++++----- src/overlays/actors/ovl_En_Kbt/z_en_kbt.h | 2 +- .../actors/ovl_En_Kendo_Js/z_en_kendo_js.c | 53 +++-- .../actors/ovl_En_Kendo_Js/z_en_kendo_js.h | 5 +- src/overlays/actors/ovl_En_Kgy/z_en_kgy.c | 191 +++++++++++------- src/overlays/actors/ovl_En_Kgy/z_en_kgy.h | 9 +- .../actors/ovl_En_Kujiya/z_en_kujiya.c | 15 ++ src/overlays/actors/ovl_En_Kusa/z_en_kusa.c | 7 + .../actors/ovl_Obj_Syokudai/z_obj_syokudai.c | 3 +- tools/disasm/functions.txt | 4 +- 17 files changed, 354 insertions(+), 195 deletions(-) diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 79af1b73f..675487072 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -1680,7 +1680,8 @@ void SkelAnime_AnimateFrame(SkelAnime* skelAnime) { s32 frame = skelAnime->curFrame; f32 partialFrame = skelAnime->curFrame - frame; - if (++frame >= (s32)skelAnime->animLength) { + frame++; + if (frame >= (s32)skelAnime->animLength) { frame = 0; } SkelAnime_GetFrameData(skelAnime->animation, frame, skelAnime->limbCount, nextjointTable); diff --git a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c index 39269c2ac..08f97aa93 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -3931,10 +3931,11 @@ void EnFishing_UpdateFish(Actor* thisx, PlayState* play2) { SkelAnime_Free(&this->skelAnime, play); if (this->unk_148 == 0) { - SkelAnime_InitFlex(play, &this->skelAnime, &gFishingBassSkel, &gFishingBassAnim, 0, 0, 0); + SkelAnime_InitFlex(play, &this->skelAnime, &gFishingBassSkel, &gFishingBassAnim, NULL, NULL, 0); Animation_MorphToLoop(&this->skelAnime, &gFishingBassAnim, 0.0f); } else { - SkelAnime_InitFlex(play, &this->skelAnime, &gFishingLoachSkel, &gFishingLoachAnim, 0, 0, 0); + SkelAnime_InitFlex(play, &this->skelAnime, &gFishingLoachSkel, &gFishingLoachAnim, NULL, NULL, + 0); Animation_MorphToLoop(&this->skelAnime, &gFishingLoachAnim, 0.0f); } } diff --git a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c index 7fcf32bf4..e00f3b523 100644 --- a/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c +++ b/src/overlays/actors/ovl_En_Guard_Nuts/z_en_guard_nuts.c @@ -329,7 +329,8 @@ void EnGuardNuts_Update(Actor* thisx, PlayState* play) { s32 pad; if (this->blinkTimer == 0) { - if (++(this->eyeState) >= 3) { + this->eyeState++; + if (this->eyeState >= 3) { this->eyeState = 0; this->blinkTimer = (s16)Rand_ZeroFloat(60.0f) + 20; } diff --git a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c index cee6b38fa..d629c57b9 100644 --- a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c +++ b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c @@ -442,8 +442,8 @@ s32 func_80B85A00(EnKaizoku* this, PlayState* play, s16 arg2) { void EnKaizoku_ChangeAnim(EnKaizoku* this, EnKaizokuAnimation animIndex) { this->animIndex = animIndex; - this->frameCount = Animation_GetLastFrame(sAnimations[this->animIndex]); - Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.0f, this->frameCount, + this->animEndFrame = Animation_GetLastFrame(sAnimations[this->animIndex]); + Animation_Change(&this->skelAnime, sAnimations[this->animIndex], 1.0f, 0.0f, this->animEndFrame, sAnimationModes[this->animIndex], 0.0f); } @@ -553,7 +553,7 @@ void func_80B85FA8(EnKaizoku* this, PlayState* play) { break; case 3: - if (this->frameCount <= curFrame) { + if (curFrame >= this->animEndFrame) { sp54 = this->unk_2CA * 4 + this->unk_2C8; if (Player_GetMask(play) == PLAYER_MASK_STONE) { if (D_80B8A8D0[sp54] == 0x11A5) { @@ -595,7 +595,7 @@ void func_80B85FA8(EnKaizoku* this, PlayState* play) { case 6: Math_ApproachF(&this->unk_5E0, 5.0f, 0.3f, 1.0f); - if (this->frameCount <= curFrame) { + if (curFrame >= this->animEndFrame) { this->unk_598 = 7; this->unk_2F8.x = 1.0f; this->unk_59C++; @@ -700,7 +700,7 @@ void func_80B868B8(EnKaizoku* this, PlayState* play) { switch (this->unk_59C) { case 0: - if (this->frameCount <= curFrame) { + if (curFrame >= this->animEndFrame) { EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_14); this->unk_2C8 = 3; this->unk_598 = 0; @@ -709,7 +709,7 @@ void func_80B868B8(EnKaizoku* this, PlayState* play) { break; case 1: - if (this->frameCount <= curFrame) { + if (curFrame >= this->animEndFrame) { s32 textId; EnKaizoku_ChangeAnim(this, EN_KAIZOKU_ANIM_15); @@ -787,7 +787,7 @@ void func_80B86B74(EnKaizoku* this, PlayState* play) { break; case 1: - if (this->frameCount <= curFrame) { + if (curFrame >= this->animEndFrame) { if (this->unk_2D9 == 0) { Actor_PlaySfx(&this->picto.actor, NA_SE_EN_PIRATE_DAMM_BREATH); this->unk_2D9 = 1; @@ -843,7 +843,7 @@ void func_80B86B74(EnKaizoku* this, PlayState* play) { 255; } - if ((this->frameCount <= curFrame) && (this->unk_5A0 >= 0x28)) { + if ((curFrame >= this->animEndFrame) && (this->unk_5A0 >= 0x28)) { this->picto.actor.draw = NULL; this->unk_598 = 10; Math_Vec3f_Copy(&this->unk_2F8, &gZeroVec3f); @@ -1127,7 +1127,7 @@ void func_80B87D3C(EnKaizoku* this, PlayState* play) { } this->unk_2D8 = 0; - if ((this->frameCount <= curFrame) && + if ((curFrame >= this->animEndFrame) && (this->picto.actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH))) { this->bodyCollider.info.elemType = ELEMTYPE_UNK1; this->bodyCollider.base.colType = COLTYPE_HIT3; @@ -1157,7 +1157,7 @@ void func_80B87E9C(EnKaizoku* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; this->unk_2D8 = 0; - if (this->frameCount <= curFrame) { + if (curFrame >= this->animEndFrame) { if ((this->picto.actor.xzDistToPlayer < 170.0f) && (this->picto.actor.xzDistToPlayer > 140.0f) && (Rand_ZeroOne() < 0.2f)) { func_80B88910(this); @@ -1207,7 +1207,7 @@ void func_80B87FDC(EnKaizoku* this, PlayState* play2) { } this->unk_2D8 = 0; - if (this->frameCount <= curFrame) { + if (curFrame >= this->animEndFrame) { if (!Actor_IsFacingPlayer(&this->picto.actor, 0x1554)) { func_80B872A4(this); @@ -1252,7 +1252,7 @@ void func_80B88278(EnKaizoku* this, PlayState* play) { f32 curFrame = this->skelAnime.curFrame; this->unk_2D8 = 0; - if (this->frameCount <= curFrame) { + if (curFrame >= this->animEndFrame) { this->picto.actor.speed = 0.0f; if (!Actor_IsFacingPlayer(&this->picto.actor, 0x1554)) { func_80B872A4(this); @@ -1404,22 +1404,20 @@ void func_80B88964(EnKaizoku* this, PlayState* play) { if (this->skelAnime.curFrame <= 8.0f) { this->picto.actor.shape.rot.y = this->picto.actor.world.rot.y = this->picto.actor.yawTowardsPlayer; - } else { - if (Animation_OnFrame(&this->skelAnime, 13.0f)) { - Actor_SpawnFloorDustRing(play, &this->picto.actor, &this->leftFootPos, 3.0f, 2, 2.0f, 0, 0, 0); - Actor_SpawnFloorDustRing(play, &this->picto.actor, &this->rightFootPos, 3.0f, 2, 2.0f, 0, 0, 0); - this->swordState = 1; - this->picto.actor.speed = 10.0f; - Actor_PlaySfx(&this->picto.actor, NA_SE_EN_PIRATE_ATTACK); - } else if (Animation_OnFrame(&this->skelAnime, 21.0f)) { - this->picto.actor.speed = 0.0f; - } else if (Animation_OnFrame(&this->skelAnime, 24.0f)) { - this->swordState = -1; - } + } else if (Animation_OnFrame(&this->skelAnime, 13.0f)) { + Actor_SpawnFloorDustRing(play, &this->picto.actor, &this->leftFootPos, 3.0f, 2, 2.0f, 0, 0, 0); + Actor_SpawnFloorDustRing(play, &this->picto.actor, &this->rightFootPos, 3.0f, 2, 2.0f, 0, 0, 0); + this->swordState = 1; + this->picto.actor.speed = 10.0f; + Actor_PlaySfx(&this->picto.actor, NA_SE_EN_PIRATE_ATTACK); + } else if (Animation_OnFrame(&this->skelAnime, 21.0f)) { + this->picto.actor.speed = 0.0f; + } else if (Animation_OnFrame(&this->skelAnime, 24.0f)) { + this->swordState = -1; } this->unk_2D8 = 0; - if ((this->frameCount <= curFrame) && (this->unk_2D0 < 2)) { + if ((curFrame >= this->animEndFrame) && (this->unk_2D0 < 2)) { if (!Actor_IsFacingPlayer(&this->picto.actor, 0x1554)) { func_80B872A4(this); this->unk_2B2 = Rand_ZeroOne() * 5.0f + 5.0f; @@ -1755,7 +1753,7 @@ void func_80B8971C(EnKaizoku* this, PlayState* play) { Math_SmoothStepToS(&this->picto.actor.shape.rot.y, this->picto.actor.yawTowardsPlayer, 1, 0xFA0, 1); SkelAnime_Update(&this->skelAnime); - if (this->frameCount <= curFrame) { + if (curFrame >= this->animEndFrame) { this->unk_2D8 = 0; func_80B86B58(this); } else if (Animation_OnFrame(&this->skelAnime, 10.0f)) { diff --git a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.h b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.h index e2c53d34b..a119777a9 100644 --- a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.h +++ b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.h @@ -80,7 +80,7 @@ typedef struct EnKaizoku { /* 0x2D6 */ s16 csId; /* 0x2D8 */ u8 unk_2D8; /* 0x2D9 */ u8 unk_2D9; - /* 0x2DC */ f32 frameCount; + /* 0x2DC */ f32 animEndFrame; /* 0x2E0 */ f32 unk_2E0; /* 0x2E4 */ EnKaizokuAnimation animIndex; /* 0x2E8 */ s32 bodyPartIndex; diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c index be787e8d9..d2c877ad3 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -121,18 +121,32 @@ typedef enum { /* 5 */ ENKAKASI_ANIM_ARMS_CROSSED_STILL, // arms crossed but still, also some noise sfx /* 6 */ ENKAKASI_ANIM_WAVE, // "wave" short sideways shake, stops early, partial? unused? /* 7 */ ENKAKASI_ANIM_SLOWROLL, // partial bounch, ends looking left, OFFER anim takes over - /* 8 */ ENKAKASI_ANIM_IDLE // slow stretching wiggle, ends in regular position + /* 8 */ ENKAKASI_ANIM_IDLE, // slow stretching wiggle, ends in regular position + /* 9 */ ENKAKASI_ANIM_MAX } EnKakasiAnimation; -static AnimationHeader* sAnimations[] = { - &object_ka_Anim_007444, &object_ka_Anim_00686C, &object_ka_Anim_0081A4, - &object_ka_Anim_007B90, &object_ka_Anim_0071EC, &object_ka_Anim_007444, - &object_ka_Anim_00686C, &object_ka_Anim_0081A4, &object_ka_Anim_000214, +static AnimationHeader* sAnimations[ENKAKASI_ANIM_MAX] = { + &object_ka_Anim_007444, // ENKAKASI_ANIM_ARMS_CROSSED_ROCKING + &object_ka_Anim_00686C, // ENKAKASI_ANIM_SIDEWAYS_SHAKING + &object_ka_Anim_0081A4, // ENKAKASI_ANIM_HOPPING_REGULAR + &object_ka_Anim_007B90, // ENKAKASI_ANIM_SPIN_REACH_OFFER + &object_ka_Anim_0071EC, // ENKAKASI_ANIM_TWIRL + &object_ka_Anim_007444, // ENKAKASI_ANIM_ARMS_CROSSED_STILL + &object_ka_Anim_00686C, // ENKAKASI_ANIM_WAVE + &object_ka_Anim_0081A4, // ENKAKASI_ANIM_SLOWROLL + &object_ka_Anim_000214, // ENKAKASI_ANIM_IDLE }; -static u8 sAnimationModes[] = { - ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, - ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, +static u8 sAnimationModes[ENKAKASI_ANIM_MAX] = { + ANIMMODE_LOOP, // ENKAKASI_ANIM_ARMS_CROSSED_ROCKING + ANIMMODE_LOOP, // ENKAKASI_ANIM_SIDEWAYS_SHAKING + ANIMMODE_LOOP, // ENKAKASI_ANIM_HOPPING_REGULAR + ANIMMODE_ONCE, // ENKAKASI_ANIM_SPIN_REACH_OFFER + ANIMMODE_ONCE, // ENKAKASI_ANIM_TWIRL + ANIMMODE_ONCE, // ENKAKASI_ANIM_ARMS_CROSSED_STILL + ANIMMODE_ONCE, // ENKAKASI_ANIM_WAVE + ANIMMODE_ONCE, // ENKAKASI_ANIM_SLOWROLL + ANIMMODE_ONCE, // ENKAKASI_ANIM_IDLE }; void EnKakasi_Destroy(Actor* thisx, PlayState* play) { @@ -147,7 +161,7 @@ void EnKakasi_Init(Actor* thisx, PlayState* play) { s32 i; Collider_InitAndSetCylinder(play, &this->collider, &this->picto.actor, &D_80971D80); - SkelAnime_InitFlex(play, &this->skelAnime, &object_ka_Skel_0065B0, &object_ka_Anim_000214, 0, 0, 0); + SkelAnime_InitFlex(play, &this->skelAnime, &object_ka_Skel_0065B0, &object_ka_Anim_000214, NULL, NULL, 0); this->songSummonDist = KAKASI_GET_SUMMON_DISTANCE(&this->picto.actor) * 20.0f; if (this->songSummonDist < 40.0f) { @@ -278,7 +292,6 @@ void func_8096FBB8(EnKakasi* this, PlayState* play) { (play->msgCtx.ocarinaButtonIndex == OCARINA_BTN_C_RIGHT) || (play->msgCtx.ocarinaButtonIndex == OCARINA_BTN_C_LEFT) || (play->msgCtx.ocarinaButtonIndex == OCARINA_BTN_C_UP)) { - // why not 0 < x < 4? fewer branches this->unk190++; } if ((this->unk190 != 0) && (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING)) { @@ -364,7 +377,7 @@ void EnKakasi_IdleStanding(EnKakasi* this, PlayState* play) { } else if ((day == 3) && gSaveContext.save.isNight) { this->skelAnime.playSpeed = 1.0f; if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { - EnKakasi_ChangeAnim(this, 1); + EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); } } else if (this->animIndex != ENKAKASI_ANIM_IDLE) { EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_IDLE); @@ -403,7 +416,8 @@ void EnKakasi_RegularDialogue(EnKakasi* this, PlayState* play) { // if dialogue: oh sorry come back again if ((this->picto.actor.textId == 0x1651) || (this->picto.actor.textId == 0x1659)) { if ((curFrame >= this->animEndFrame) && (this->animIndex != ENKAKASI_ANIM_SPIN_REACH_OFFER)) { - if (++this->unkCounter1A4 >= 2) { + this->unkCounter1A4++; + if (this->unkCounter1A4 >= 2) { this->unkCounter1A4 = 0; EnKakasi_ChangeAnim(this, ENKAKASI_ANIM_SPIN_REACH_OFFER); } @@ -1154,7 +1168,7 @@ void EnKakasi_Update(Actor* thisx, PlayState* play) { void EnKakasi_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnKakasi* this = THIS; - if (limbIndex == 4) { + if (limbIndex == OBJECT_KA_LIMB_04) { Matrix_MultVec3f(&gZeroVec3f, &this->unk1BC); } } diff --git a/src/overlays/actors/ovl_En_Kame/z_en_kame.c b/src/overlays/actors/ovl_En_Kame/z_en_kame.c index c400b3428..8171e56b4 100644 --- a/src/overlays/actors/ovl_En_Kame/z_en_kame.c +++ b/src/overlays/actors/ovl_En_Kame/z_en_kame.c @@ -647,10 +647,10 @@ void EnKame_Stunned(EnKame* this, PlayState* play) { } void EnKame_SetupDamaged(EnKame* this) { - s16 lastFrame = Animation_GetLastFrame(&gSnapperDamageAnim); + s16 endFrame = Animation_GetLastFrame(&gSnapperDamageAnim); - Animation_Change(&this->snapperSkelAnime, &gSnapperDamageAnim, 1.0f, 0.0f, lastFrame, ANIMMODE_ONCE, -3.0f); - Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, lastFrame); + Animation_Change(&this->snapperSkelAnime, &gSnapperDamageAnim, 1.0f, 0.0f, endFrame, ANIMMODE_ONCE, -3.0f); + Actor_SetColorFilter(&this->actor, COLORFILTER_COLORFLAG_RED, 255, COLORFILTER_BUFFLAG_OPA, endFrame); Actor_PlaySfx(&this->actor, NA_SE_EN_PAMET_DAMAGE); this->collider.base.acFlags &= ~AC_ON; this->actionFunc = EnKame_Damaged; diff --git a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c index 76d88fa94..01e781ecb 100644 --- a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c +++ b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.c @@ -17,11 +17,28 @@ void EnKbt_Draw(Actor* thisx, PlayState* play); s32 func_80B33E64(PlayState* play); s32 func_80B33E8C(PlayState* play); -void func_80B33EF0(EnKbt* this, s16 arg1); +void EnKbt_ChangeAnim(EnKbt* this, s16 animIndex); Actor* func_80B3403C(PlayState* play); void func_80B34314(EnKbt* this, PlayState* play); void func_80B34598(EnKbt* this, PlayState* play); +typedef enum EnKbtAnimation { + /* 0 */ ENKBT_ANIM_0, + /* 1 */ ENKBT_ANIM_1, + /* 2 */ ENKBT_ANIM_2, + /* 3 */ ENKBT_ANIM_3, + /* 4 */ ENKBT_ANIM_4, + /* 5 */ ENKBT_ANIM_5, + /* 6 */ ENKBT_ANIM_6, + /* 7 */ ENKBT_ANIM_7, + /* 8 */ ENKBT_ANIM_8, + /* 9 */ ENKBT_ANIM_9, + /* 10 */ ENKBT_ANIM_10, + /* 11 */ ENKBT_ANIM_11, + /* 12 */ ENKBT_ANIM_12, + /* 13 */ ENKBT_ANIM_MAX +} EnKbtAnimation; + ActorInit En_Kbt_InitVars = { ACTOR_EN_KBT, ACTORCAT_NPC, @@ -44,13 +61,13 @@ void EnKbt_Init(Actor* thisx, PlayState* play) { this->actor.home.rot.z = 0; this->unk_27E = 4; this->unk_27F = 0; - this->unk_280 = 13; + this->animIndex = ENKBT_ANIM_MAX; this->unk_282 = 13; this->unk_278 = func_80B3403C(play); this->unk_284 = 0; this->actor.textId = 0; if (func_80B33E64(play)) { - func_80B33EF0(this, 6); + EnKbt_ChangeAnim(this, ENKBT_ANIM_6); this->unk_282 = 11; if (func_80B33E8C(play)) { this->actor.textId = 0xC50; @@ -60,7 +77,7 @@ void EnKbt_Init(Actor* thisx, PlayState* play) { } this->actionFunc = func_80B34314; } else { - func_80B33EF0(this, 0); + EnKbt_ChangeAnim(this, ENKBT_ANIM_0); this->unk_282 = 0; this->actionFunc = func_80B34598; } @@ -82,27 +99,48 @@ s32 func_80B33E8C(PlayState* play) { return false; } -void func_80B33EF0(EnKbt* this, s16 arg1) { - static AnimationHeader* sAnimations[] = { - &object_kbt_Anim_000670, &object_kbt_Anim_001674, &object_kbt_Anim_002084, &object_kbt_Anim_000FE8, - &object_kbt_Anim_001940, &object_kbt_Anim_00E7BC, &object_kbt_Anim_00F0C8, &object_kbt_Anim_002710, - &object_kbt_Anim_002DE0, &object_kbt_Anim_003414, &object_kbt_Anim_003D24, &object_kbt_Anim_001BF4, - &object_kbt_Anim_002084, +void EnKbt_ChangeAnim(EnKbt* this, s16 animIndex) { + static AnimationHeader* sAnimations[ENKBT_ANIM_MAX] = { + &object_kbt_Anim_000670, // ENKBT_ANIM_0 + &object_kbt_Anim_001674, // ENKBT_ANIM_1 + &object_kbt_Anim_002084, // ENKBT_ANIM_2 + &object_kbt_Anim_000FE8, // ENKBT_ANIM_3 + &object_kbt_Anim_001940, // ENKBT_ANIM_4 + &object_kbt_Anim_00E7BC, // ENKBT_ANIM_5 + &object_kbt_Anim_00F0C8, // ENKBT_ANIM_6 + &object_kbt_Anim_002710, // ENKBT_ANIM_7 + &object_kbt_Anim_002DE0, // ENKBT_ANIM_8 + &object_kbt_Anim_003414, // ENKBT_ANIM_9 + &object_kbt_Anim_003D24, // ENKBT_ANIM_10 + &object_kbt_Anim_001BF4, // ENKBT_ANIM_11 + &object_kbt_Anim_002084, // ENKBT_ANIM_12 }; - u8 sp38[] = { - ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_LOOP, ANIMMODE_LOOP, - ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, + u8 animationModes[ENKBT_ANIM_MAX] = { + ANIMMODE_LOOP, // ENKBT_ANIM_0 + ANIMMODE_LOOP, // ENKBT_ANIM_1 + ANIMMODE_ONCE, // ENKBT_ANIM_2 + ANIMMODE_LOOP, // ENKBT_ANIM_3 + ANIMMODE_ONCE, // ENKBT_ANIM_4 + ANIMMODE_LOOP, // ENKBT_ANIM_5 + ANIMMODE_LOOP, // ENKBT_ANIM_6 + ANIMMODE_LOOP, // ENKBT_ANIM_7 + ANIMMODE_LOOP, // ENKBT_ANIM_8 + ANIMMODE_LOOP, // ENKBT_ANIM_9 + ANIMMODE_LOOP, // ENKBT_ANIM_10 + ANIMMODE_ONCE, // ENKBT_ANIM_11 + ANIMMODE_ONCE, // ENKBT_ANIM_12 }; - if (arg1 != this->unk_280) { - if (arg1 >= 12) { - Animation_Change(&this->skelAnime, sAnimations[arg1], -1.0f, - Animation_GetLastFrame(sAnimations[arg1]) - 1.0f, 0.0f, sp38[arg1], -5.0f); + if (this->animIndex != animIndex) { + if (animIndex >= ENKBT_ANIM_12) { + Animation_Change(&this->skelAnime, sAnimations[animIndex], -1.0f, + Animation_GetLastFrame(sAnimations[animIndex]) - 1.0f, 0.0f, animationModes[animIndex], + -5.0f); } else { - Animation_Change(&this->skelAnime, sAnimations[arg1], 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[arg1]), - sp38[arg1], -5.0f); + Animation_Change(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(sAnimations[animIndex]), animationModes[animIndex], -5.0f); } - this->unk_280 = arg1; + this->animIndex = animIndex; } } @@ -124,11 +162,11 @@ void func_80B34078(EnKbt* this) { if (this->unk_284 > 0) { this->unk_284--; } else { - switch (this->unk_280) { - case 2: + switch (this->animIndex) { + case ENKBT_ANIM_2: switch (this->unk_282) { case 0: - func_80B33EF0(this, 12); + EnKbt_ChangeAnim(this, ENKBT_ANIM_12); break; case 5: @@ -136,21 +174,24 @@ void func_80B34078(EnKbt* this) { break; default: - func_80B33EF0(this, 5); + EnKbt_ChangeAnim(this, ENKBT_ANIM_5); break; } break; - case 12: - func_80B33EF0(this, 0); + case ENKBT_ANIM_12: + EnKbt_ChangeAnim(this, ENKBT_ANIM_0); this->actor.home.rot.z = 0; break; - case 4: - func_80B33EF0(this, 1); + case ENKBT_ANIM_4: + EnKbt_ChangeAnim(this, ENKBT_ANIM_1); this->unk_27E = 2; this->actor.home.rot.z = 0; break; + + default: + break; } } } @@ -169,67 +210,70 @@ void func_80B3415C(EnKbt* this) { switch (this->unk_282) { case 0: - if ((this->unk_280 != 2) && (this->unk_280 != 12)) { - func_80B33EF0(this, 0); + if ((this->animIndex != ENKBT_ANIM_2) && (this->animIndex != ENKBT_ANIM_12)) { + EnKbt_ChangeAnim(this, ENKBT_ANIM_0); } break; case 1: - func_80B33EF0(this, 2); + EnKbt_ChangeAnim(this, ENKBT_ANIM_2); this->unk_282 = 0; break; case 2: - if (this->unk_280 != 12) { - func_80B33EF0(this, 3); + if (this->animIndex != ENKBT_ANIM_12) { + EnKbt_ChangeAnim(this, ENKBT_ANIM_3); } break; case 3: - if (this->unk_280 != 1) { - func_80B33EF0(this, 4); + if (this->animIndex != ENKBT_ANIM_1) { + EnKbt_ChangeAnim(this, ENKBT_ANIM_4); } break; case 10: - func_80B33EF0(this, 11); + EnKbt_ChangeAnim(this, ENKBT_ANIM_11); break; case 4: - func_80B33EF0(this, 2); + EnKbt_ChangeAnim(this, ENKBT_ANIM_2); this->unk_282 = 6; break; case 6: - if (this->unk_280 != 2) { - func_80B33EF0(this, 5); + if (this->animIndex != ENKBT_ANIM_2) { + EnKbt_ChangeAnim(this, ENKBT_ANIM_5); } break; case 11: - func_80B33EF0(this, 6); + EnKbt_ChangeAnim(this, ENKBT_ANIM_6); break; case 7: - if (this->unk_280 != 2) { - func_80B33EF0(this, 7); + if (this->animIndex != ENKBT_ANIM_2) { + EnKbt_ChangeAnim(this, ENKBT_ANIM_7); } break; case 8: - if (this->unk_280 != 2) { - func_80B33EF0(this, 8); + if (this->animIndex != ENKBT_ANIM_2) { + EnKbt_ChangeAnim(this, ENKBT_ANIM_8); } break; case 9: - if (this->unk_280 != 2) { - func_80B33EF0(this, 9); + if (this->animIndex != ENKBT_ANIM_2) { + EnKbt_ChangeAnim(this, ENKBT_ANIM_9); } break; case 12: - func_80B33EF0(this, 10); + EnKbt_ChangeAnim(this, ENKBT_ANIM_10); + break; + + default: break; } } @@ -327,7 +371,7 @@ void func_80B34598(EnKbt* this, PlayState* play) { this->unk_27E = 4; this->unk_27F = 0; this->unk_282 = 0; - func_80B33EF0(this, 12); + EnKbt_ChangeAnim(this, ENKBT_ANIM_12); break; case 0x6: @@ -411,26 +455,26 @@ void func_80B34598(EnKbt* this, PlayState* play) { case 0xC35: this->unk_27E = 4; this->unk_27F = 0; - func_80B33EF0(this, 2); + EnKbt_ChangeAnim(this, ENKBT_ANIM_2); this->unk_282 = 5; break; case 0xC36: this->unk_27E = 1; this->unk_27F = 1; - func_80B33EF0(this, 7); + EnKbt_ChangeAnim(this, ENKBT_ANIM_7); this->unk_282 = 7; break; case 0xC37: - func_80B33EF0(this, 10); + EnKbt_ChangeAnim(this, ENKBT_ANIM_10); this->unk_27E = 0; this->unk_27F = 1; break; case 0xC38: case 0xC39: - func_80B33EF0(this, 7); + EnKbt_ChangeAnim(this, ENKBT_ANIM_7); this->unk_27E = 0; this->unk_27F = 1; break; @@ -517,6 +561,9 @@ void func_80B34598(EnKbt* this, PlayState* play) { this->unk_27F = 1; this->unk_282 = 12; break; + + default: + break; } this->actor.textId = 0; diff --git a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h index eb491bf28..9a7a5cdf0 100644 --- a/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h +++ b/src/overlays/actors/ovl_En_Kbt/z_en_kbt.h @@ -17,7 +17,7 @@ typedef struct EnKbt { /* 0x27C */ u16 unk_27C; /* 0x27E */ u8 unk_27E; /* 0x27F */ u8 unk_27F; - /* 0x280 */ s16 unk_280; + /* 0x280 */ s16 animIndex; /* 0x282 */ s16 unk_282; /* 0x284 */ s16 unk_284; /* 0x288 */ EnKbtActionFunc actionFunc; diff --git a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c index ce3011e6d..31d98abf0 100644 --- a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c +++ b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c @@ -6,7 +6,6 @@ #include "z_en_kendo_js.h" #include "overlays/actors/ovl_En_Maruta/z_en_maruta.h" -#include "objects/object_js/object_js.h" #define FLAGS \ (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_FRIENDLY | ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_CANT_LOCK_ON) @@ -72,12 +71,21 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static AnimationInfo sAnimationInfo[] = { - { &object_js_Anim_000C7C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_js_Anim_000F4C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_js_Anim_00016C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, - { &object_js_Anim_0003DC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, - { &object_js_Anim_000AD4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, +typedef enum EnKendoJsAnimation { + /* 0 */ ENKENDOJS_ANIM_0, + /* 1 */ ENKENDOJS_ANIM_1, + /* 2 */ ENKENDOJS_ANIM_2, + /* 3 */ ENKENDOJS_ANIM_3, + /* 4 */ ENKENDOJS_ANIM_4, + /* 5 */ ENKENDOJS_ANIM_MAX +} EnKendoJsAnimation; + +static AnimationInfo sAnimationInfo[ENKENDOJS_ANIM_MAX] = { + { &object_js_Anim_000C7C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, // ENKENDOJS_ANIM_0 + { &object_js_Anim_000F4C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, // ENKENDOJS_ANIM_1 + { &object_js_Anim_00016C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, // ENKENDOJS_ANIM_2 + { &object_js_Anim_0003DC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, // ENKENDOJS_ANIM_3 + { &object_js_Anim_000AD4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, // ENKENDOJS_ANIM_4 }; s16 D_80B27CE0[][3] = { @@ -110,7 +118,7 @@ void EnKendoJs_Init(Actor* thisx, PlayState* play) { CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); SkelAnime_InitFlex(play, &this->skelAnime, &object_js_Skel_006990, &object_js_Anim_000F4C, this->jointTable, - this->morphTable, 13); + this->morphTable, OBJECT_JS_LIMB_MAX); if ((CURRENT_DAY == 3) && !((gSaveContext.save.time <= CLOCK_TIME(23, 0)) && (gSaveContext.save.time >= CLOCK_TIME(6, 0)))) { @@ -120,7 +128,7 @@ void EnKendoJs_Init(Actor* thisx, PlayState* play) { this->actor.home.rot.z, 0x10); Actor_Kill(&this->actor); } else { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENKENDOJS_ANIM_4); } } else if (ENKENDOJS_GET_FF(&this->actor) == ENKENDOJS_FF_1) { Actor_Kill(&this->actor); @@ -224,7 +232,7 @@ void func_80B26758(EnKendoJs* this, PlayState* play) { Audio_PlaySfx(NA_SE_SY_ERROR); Message_StartTextbox(play, 0x272C, &this->actor); this->unk_288 = 0x272C; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENKENDOJS_ANIM_2); } else if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk1206C) { Audio_PlaySfx(NA_SE_SY_ERROR); Message_StartTextbox(play, 0x2718, &this->actor); @@ -242,7 +250,7 @@ void func_80B26758(EnKendoJs* this, PlayState* play) { Audio_PlaySfx(NA_SE_SY_ERROR); Message_StartTextbox(play, 0x272C, &this->actor); this->unk_288 = 0x272C; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENKENDOJS_ANIM_2); } else if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk12070) { Audio_PlaySfx(NA_SE_SY_ERROR); Message_StartTextbox(play, 0x2718, &this->actor); @@ -259,6 +267,9 @@ void func_80B26758(EnKendoJs* this, PlayState* play) { Audio_PlaySfx_MessageCancel(); Message_StartTextbox(play, 0x2717, &this->actor); this->unk_288 = 0x2717; + + default: + break; } } } @@ -310,6 +321,9 @@ void func_80B269A4(EnKendoJs* this, PlayState* play) { func_80B276C4(this); func_80B276D8(this, play); break; + + default: + break; } } @@ -332,7 +346,7 @@ void func_80B26AFC(EnKendoJs* this, PlayState* play) { case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { if (this->unk_288 == 0x272C) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENKENDOJS_ANIM_3); } if ((this->unk_288 == 0x272E) || (this->unk_288 == 0x272F) || (this->unk_288 == 0x2730)) { @@ -347,6 +361,7 @@ void func_80B26AFC(EnKendoJs* this, PlayState* play) { case TEXT_STATE_1: case TEXT_STATE_CLOSING: case TEXT_STATE_3: + default: break; } } @@ -443,6 +458,9 @@ s32 func_80B26BF8(EnKendoJs* this, PlayState* play) { return 1; } break; + + default: + break; } return 2; } @@ -477,6 +495,9 @@ s32 func_80B26F6C(EnKendoJs* this, PlayState* play) { return true; } break; + + default: + break; } return false; } @@ -523,7 +544,7 @@ void func_80B27188(EnKendoJs* this, PlayState* play) { func_80B26F14(this, play); } else if (!func_80B26F6C(this, play)) { if (this->skelAnime.animation == &object_js_Anim_00016C) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENKENDOJS_ANIM_3); } this->unk_286 = 2; Message_CloseTextbox(play); @@ -548,7 +569,7 @@ void func_80B27188(EnKendoJs* this, PlayState* play) { player->stateFlags1 |= PLAYER_STATE1_20; Message_StartTextbox(play, 0x2729, &this->actor); this->unk_288 = 0x2729; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENKENDOJS_ANIM_2); break; default: @@ -564,7 +585,7 @@ void func_80B27188(EnKendoJs* this, PlayState* play) { if ((this->skelAnime.animation == &object_js_Anim_0003DC) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENKENDOJS_ANIM_1); } if (this->unk_284 == 7) { @@ -764,7 +785,7 @@ void EnKendoJs_Update(Actor* thisx, PlayState* play) { s32 EnKendoJs_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnKendoJs* this = THIS; - if (limbIndex == 12) { + if (limbIndex == OBJECT_JS_LIMB_0C) { rot->y -= this->unk_278.y; } return false; diff --git a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h index 1992f7234..8602550e0 100644 --- a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h +++ b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.h @@ -2,6 +2,7 @@ #define Z_EN_KENDO_JS_H #include "global.h" +#include "objects/object_js/object_js.h" struct EnKendoJs; @@ -17,8 +18,8 @@ typedef struct EnKendoJs { /* 0x144 */ ColliderCylinder collider; /* 0x190 */ SkelAnime skelAnime; /* 0x1D4 */ EnKendoJsActionFunc actionFunc; - /* 0x1D8 */ Vec3s jointTable[13]; - /* 0x226 */ Vec3s morphTable[13]; + /* 0x1D8 */ Vec3s jointTable[OBJECT_JS_LIMB_MAX]; + /* 0x226 */ Vec3s morphTable[OBJECT_JS_LIMB_MAX]; /* 0x274 */ Vec3s* unk_274; /* 0x278 */ Vec3s unk_278; /* 0x27E */ Vec3s unk_27E; diff --git a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c index b5819e333..62d4a1f62 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.c @@ -5,7 +5,6 @@ */ #include "z_en_kgy.h" -#include "objects/object_kgy/object_kgy.h" #include "objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_FRIENDLY) @@ -31,6 +30,21 @@ void func_80B425A0(EnKgy* this, PlayState* play); void func_80B42714(EnKgy* this, PlayState* play); void func_80B42D28(EnKgy* this, PlayState* play); +typedef enum EnKgyAnimation { + /* -1 */ ENKGY_ANIM_NONE = -1, + /* 0 */ ENKGY_ANIM_0, + /* 1 */ ENKGY_ANIM_1, + /* 2 */ ENKGY_ANIM_2, + /* 3 */ ENKGY_ANIM_3, + /* 4 */ ENKGY_ANIM_4, + /* 5 */ ENKGY_ANIM_5, + /* 6 */ ENKGY_ANIM_6, + /* 7 */ ENKGY_ANIM_7, + /* 8 */ ENKGY_ANIM_8, + /* 9 */ ENKGY_ANIM_9, + /* 10 */ ENKGY_ANIM_MAX +} EnKgyAnimation; + ActorInit En_Kgy_InitVars = { ACTOR_EN_KGY, ACTORCAT_NPC, @@ -50,11 +64,11 @@ void EnKgy_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.01f); SkelAnime_InitFlex(play, &this->skelAnime, &object_kgy_Skel_00F910, &object_kgy_Anim_004B98, this->jointTable, - this->morphTable, 23); - this->unk_2D2 = -1; + this->morphTable, OBJECT_KGY_LIMB_MAX); + this->animIndex = ENKGY_ANIM_NONE; this->unk_29C = 0; this->unk_2E4 = 0; - this->unk_2E2 = -1; + this->animIndex2 = ENKGY_ANIM_NONE; this->zubora = EnKgy_FindZubora(play); this->iceBlock = EnKgy_FindIceBlock(play); Flags_UnsetSwitch(play, ENKGY_GET_FE00(&this->actor) + 1); @@ -64,25 +78,25 @@ void EnKgy_Init(Actor* thisx, PlayState* play) { play->envCtx.lightSettingOverride = 1; SET_WEEKEVENTREG(WEEKEVENTREG_21_01); if (!func_80B40D64(play)) { - EnKgy_ChangeAnim(this, 4, ANIMMODE_LOOP, 0); + EnKgy_ChangeAnim(this, ENKGY_ANIM_4, ANIMMODE_LOOP, 0); this->actionFunc = func_80B425A0; this->actor.textId = 0xC35; } else if (!func_80B40DB4(play)) { - EnKgy_ChangeAnim(this, 6, ANIMMODE_ONCE, 0); + EnKgy_ChangeAnim(this, ENKGY_ANIM_6, ANIMMODE_ONCE, 0); this->actionFunc = func_80B419B0; this->actor.textId = 0xC4E; this->unk_29C |= 1; this->getItemId = GI_RUPEE_10; } else { - EnKgy_ChangeAnim(this, 4, ANIMMODE_LOOP, 0); + EnKgy_ChangeAnim(this, ENKGY_ANIM_4, ANIMMODE_LOOP, 0); this->actionFunc = func_80B42714; this->actor.textId = 0xC50; } } else { if (CHECK_WEEKEVENTREG(WEEKEVENTREG_20_80)) { - EnKgy_ChangeAnim(this, 4, ANIMMODE_LOOP, 0); + EnKgy_ChangeAnim(this, ENKGY_ANIM_4, ANIMMODE_LOOP, 0); } else { - EnKgy_ChangeAnim(this, 0, ANIMMODE_LOOP, 0); + EnKgy_ChangeAnim(this, ENKGY_ANIM_0, ANIMMODE_LOOP, 0); } this->actionFunc = func_80B42D28; } @@ -109,21 +123,28 @@ void EnKgy_Destroy(Actor* thisx, PlayState* play) { LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); } -void EnKgy_ChangeAnim(EnKgy* this, s16 animIndex, u8 animMode, f32 morphFrames) { - static AnimationHeader* sAnimations[] = { - &object_kgy_Anim_004B98, &object_kgy_Anim_0008FC, &object_kgy_Anim_00292C, &object_kgy_Anim_0042E4, - &object_kgy_Anim_0101F0, &object_kgy_Anim_001764, &object_kgy_Anim_003334, &object_kgy_Anim_010B84, - &object_kgy_Anim_001EA4, &object_kgy_Anim_003D88, - }; +static AnimationHeader* sAnimations[ENKGY_ANIM_MAX] = { + &object_kgy_Anim_004B98, // ENKGY_ANIM_0 + &object_kgy_Anim_0008FC, // ENKGY_ANIM_1 + &object_kgy_Anim_00292C, // ENKGY_ANIM_2 + &object_kgy_Anim_0042E4, // ENKGY_ANIM_3 + &object_kgy_Anim_0101F0, // ENKGY_ANIM_4 + &object_kgy_Anim_001764, // ENKGY_ANIM_5 + &object_kgy_Anim_003334, // ENKGY_ANIM_6 + &object_kgy_Anim_010B84, // ENKGY_ANIM_7 + &object_kgy_Anim_001EA4, // ENKGY_ANIM_8 + &object_kgy_Anim_003D88, // ENKGY_ANIM_9 +}; +void EnKgy_ChangeAnim(EnKgy* this, s16 animIndex, u8 animMode, f32 morphFrames) { Animation_Change(&this->skelAnime, sAnimations[animIndex], 1.0f, 0.0f, Animation_GetLastFrame(sAnimations[animIndex]), animMode, morphFrames); - this->unk_2D2 = animIndex; + this->animIndex = animIndex; } -void func_80B40BC0(EnKgy* this, s16 arg1) { - if (arg1 != this->unk_2D2) { - EnKgy_ChangeAnim(this, arg1, ANIMMODE_LOOP, -5.0f); +void EnKgy_ChangeAnimLoopMorph(EnKgy* this, s16 animIndex) { + if (this->animIndex != animIndex) { + EnKgy_ChangeAnim(this, animIndex, ANIMMODE_LOOP, -5.0f); } } @@ -218,13 +239,13 @@ void func_80B40EE8(EnKgy* this, PlayState* play) { if (this->unk_2E4 > 0) { this->unk_2E4--; - if ((this->unk_2E4 == 0) && (this->unk_2E2 >= 0)) { - if (this->unk_2E2 == 3) { - EnKgy_ChangeAnim(this, 3, ANIMMODE_ONCE, -5.0f); + if ((this->unk_2E4 == 0) && (this->animIndex2 > ENKGY_ANIM_NONE)) { + if (this->animIndex2 == ENKGY_ANIM_3) { + EnKgy_ChangeAnim(this, ENKGY_ANIM_3, ANIMMODE_ONCE, -5.0f); } else { - func_80B40BC0(this, this->unk_2E2); + EnKgy_ChangeAnimLoopMorph(this, this->animIndex2); } - this->unk_2E2 = -1; + this->animIndex2 = ENKGY_ANIM_NONE; } } @@ -258,14 +279,14 @@ void func_80B40EE8(EnKgy* this, PlayState* play) { switch (this->actor.textId) { case 0xC22: this->unk_2E4 = 20; - this->unk_2E2 = 3; + this->animIndex2 = ENKGY_ANIM_3; break; case 0xC43: if (func_80B40D64(play)) { - func_80B40BC0(this, 7); + EnKgy_ChangeAnimLoopMorph(this, ENKGY_ANIM_7); } else { - func_80B40BC0(this, 1); + EnKgy_ChangeAnimLoopMorph(this, ENKGY_ANIM_1); } this->unk_2E4 = 30; this->actionFunc = func_80B41A48; @@ -273,7 +294,10 @@ void func_80B40EE8(EnKgy* this, PlayState* play) { case 0xC52: case 0xC54: - func_80B40BC0(this, 1); + EnKgy_ChangeAnimLoopMorph(this, ENKGY_ANIM_1); + break; + + default: break; } } @@ -288,7 +312,7 @@ void func_80B40EE8(EnKgy* this, PlayState* play) { if (this->unk_2E8 == 0) { if ((this->actor.textId == 0xC1D) || (this->actor.textId == 0xC2D)) { this->unk_2E4 = 20; - this->unk_2E2 = 3; + this->animIndex2 = ENKGY_ANIM_3; func_80B40EBC(this, play, this->actor.textId); } else { func_80B40EBC(this, play, this->actor.textId); @@ -339,6 +363,9 @@ void func_80B411DC(EnKgy* this, PlayState* play, s32 arg2) { } this->csIdIndex = 4; break; + + default: + break; } } @@ -419,16 +446,16 @@ void func_80B4163C(EnKgy* this, PlayState* play) { this->actor.focus.pos = this->unk_2A8; if (SkelAnime_Update(&this->skelAnime)) { - if (this->unk_2D2 == 6) { + if (this->animIndex == ENKGY_ANIM_6) { if (this->getItemId > GI_NONE) { - EnKgy_ChangeAnim(this, 6, ANIMMODE_ONCE, 0.0f); + EnKgy_ChangeAnim(this, ENKGY_ANIM_6, ANIMMODE_ONCE, 0.0f); this->getItemId--; } else { - EnKgy_ChangeAnim(this, 9, ANIMMODE_ONCE, -5.0f); + EnKgy_ChangeAnim(this, ENKGY_ANIM_9, ANIMMODE_ONCE, -5.0f); this->getItemId = (s32)Rand_ZeroFloat(GI_RUPEE_PURPLE - GI_RUPEE_BLUE) + GI_RUPEE_BLUE; } } else { - EnKgy_ChangeAnim(this, 6, ANIMMODE_ONCE, -5.0f); + EnKgy_ChangeAnim(this, ENKGY_ANIM_6, ANIMMODE_ONCE, -5.0f); } SkelAnime_Update(&this->skelAnime); } @@ -446,6 +473,9 @@ void func_80B4163C(EnKgy* this, PlayState* play) { this->unk_300 = 200; Actor_PlaySfx(&this->actor, NA_SE_EV_SWORD_FORGE); break; + + default: + break; } this->lightInfo.params.point.radius = this->unk_300; @@ -608,11 +638,11 @@ void func_80B41E18(EnKgy* this, PlayState* play) { s32 pad; Player* player = GET_PLAYER(play); - if (SkelAnime_Update(&this->skelAnime) && (this->unk_2D2 == 3)) { - func_80B40BC0(this, 4); + if (SkelAnime_Update(&this->skelAnime) && (this->animIndex == ENKGY_ANIM_3)) { + EnKgy_ChangeAnimLoopMorph(this, ENKGY_ANIM_4); } - if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && func_80B40E54(this) == 0) { + if ((this->unk_2E4 <= 0) && !(this->unk_29C & 2) && (func_80B40E54(this) == 0)) { switch (Message_GetState(&play->msgCtx)) { case TEXT_STATE_CHOICE: if (Message_ShouldAdvance(play)) { @@ -636,6 +666,9 @@ void func_80B41E18(EnKgy* this, PlayState* play) { Audio_PlaySfx_MessageCancel(); func_80B40EBC(this, play, textId); break; + + default: + break; } break; @@ -650,8 +683,14 @@ void func_80B41E18(EnKgy* this, PlayState* play) { Audio_PlaySfx_MessageCancel(); func_80B40E74(this, play, 0xC3C); break; + + default: + break; } break; + + default: + break; } } break; @@ -683,13 +722,13 @@ void func_80B41E18(EnKgy* this, PlayState* play) { this->actionFunc = func_80B425A0; func_80B413C8(this); func_80B40E18(this, 5); - func_80B40BC0(this, 4); + EnKgy_ChangeAnimLoopMorph(this, ENKGY_ANIM_4); this->actor.textId = 0xC35; break; case 0xC3A: func_80B40E74(this, play, func_80B41528(play)); - func_80B40BC0(this, 4); + EnKgy_ChangeAnimLoopMorph(this, ENKGY_ANIM_4); break; case 0xC3C: @@ -758,7 +797,7 @@ void func_80B41E18(EnKgy* this, PlayState* play) { break; case 0xC47: - func_80B40BC0(this, 1); + EnKgy_ChangeAnimLoopMorph(this, ENKGY_ANIM_1); if (this->unk_29C & 8) { player->exchangeItemAction = PLAYER_IA_NONE; this->unk_29C &= ~8; @@ -780,7 +819,7 @@ void func_80B41E18(EnKgy* this, PlayState* play) { case 0xC4A: case 0xC4B: - func_80B40BC0(this, 4); + EnKgy_ChangeAnimLoopMorph(this, ENKGY_ANIM_4); Message_CloseTextbox(play); this->actionFunc = func_80B41C54; this->actor.textId = 0xC4B; @@ -817,9 +856,15 @@ void func_80B41E18(EnKgy* this, PlayState* play) { func_80B413C8(this); func_80B40E18(this, 8); break; + + default: + break; } } break; + + default: + break; } } @@ -844,7 +889,7 @@ void func_80B425A0(EnKgy* this, PlayState* play) { this->actor.focus.pos = this->unk_2A8; if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B41E18; - func_80B40BC0(this, 1); + EnKgy_ChangeAnimLoopMorph(this, ENKGY_ANIM_1); func_80B411DC(this, play, 0); func_80B40E18(this, this->actor.textId); } else if (this->actor.xzDistToPlayer < 200.0f) { @@ -887,11 +932,11 @@ void func_80B427C8(EnKgy* this, PlayState* play) { u16 textId; if (SkelAnime_Update(&this->skelAnime)) { - if (this->unk_2D2 == 5) { - func_80B40BC0(this, 7); + if (this->animIndex == ENKGY_ANIM_5) { + EnKgy_ChangeAnimLoopMorph(this, ENKGY_ANIM_7); } - if (this->unk_2D2 == 3) { - func_80B40BC0(this, 4); + if (this->animIndex == ENKGY_ANIM_3) { + EnKgy_ChangeAnimLoopMorph(this, ENKGY_ANIM_4); } } @@ -923,26 +968,29 @@ void func_80B427C8(EnKgy* this, PlayState* play) { this->actionFunc = func_80B41C54; func_80B413C8(this); func_80B40E18(this, 6); - func_80B40BC0(this, 4); + EnKgy_ChangeAnimLoopMorph(this, ENKGY_ANIM_4); this->actor.textId = 0xC3A; break; + + default: + break; } } func_80B40EE8(this, play); } void func_80B4296C(EnKgy* this, PlayState* play) { - if (SkelAnime_Update(&this->skelAnime) && (this->unk_2D2 == 8)) { - func_80B40BC0(this, 2); + if (SkelAnime_Update(&this->skelAnime) && (this->animIndex == ENKGY_ANIM_8)) { + EnKgy_ChangeAnimLoopMorph(this, ENKGY_ANIM_2); } this->actor.focus.pos = this->unk_2A8; if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B427C8; - if (this->unk_2D2 == 4) { - func_80B40BC0(this, 7); + if (this->animIndex == ENKGY_ANIM_4) { + EnKgy_ChangeAnimLoopMorph(this, ENKGY_ANIM_7); } else { - EnKgy_ChangeAnim(this, 5, ANIMMODE_ONCE, -5.0f); + EnKgy_ChangeAnim(this, ENKGY_ANIM_5, ANIMMODE_ONCE, -5.0f); } func_80B411DC(this, play, 0); func_80B40E18(this, this->actor.textId); @@ -958,12 +1006,12 @@ void func_80B42A8C(EnKgy* this, PlayState* play) { s32 pad; if (SkelAnime_Update(&this->skelAnime)) { - if (this->unk_2D2 == 5) { - func_80B40BC0(this, 1); + if (this->animIndex == ENKGY_ANIM_5) { + EnKgy_ChangeAnimLoopMorph(this, ENKGY_ANIM_1); } - if (this->unk_2D2 == 3) { - func_80B40BC0(this, 4); + if (this->animIndex == ENKGY_ANIM_3) { + EnKgy_ChangeAnimLoopMorph(this, ENKGY_ANIM_4); } } @@ -995,7 +1043,7 @@ void func_80B42A8C(EnKgy* this, PlayState* play) { case 0xC20: case 0xC28: - func_80B40BC0(this, 1); + EnKgy_ChangeAnimLoopMorph(this, ENKGY_ANIM_1); play->msgCtx.msgLength = 0; this->unk_29C |= 4; this->unk_2E8 = 3; @@ -1027,7 +1075,7 @@ void func_80B42A8C(EnKgy* this, PlayState* play) { case 0xC2A: this->unk_2E4 = 20; - this->unk_2E2 = 3; + this->animIndex2 = ENKGY_ANIM_3; func_80B40EBC(this, play, this->actor.textId); break; @@ -1038,23 +1086,26 @@ void func_80B42A8C(EnKgy* this, PlayState* play) { func_80B413C8(this); func_80B40E18(this, 1); break; + + default: + break; } } func_80B40EE8(this, play); } void func_80B42D28(EnKgy* this, PlayState* play) { - if (SkelAnime_Update(&this->skelAnime) && (this->unk_2D2 == 8)) { - func_80B40BC0(this, 2); + if (SkelAnime_Update(&this->skelAnime) && (this->animIndex == ENKGY_ANIM_8)) { + EnKgy_ChangeAnimLoopMorph(this, ENKGY_ANIM_2); } this->actor.focus.pos = this->unk_2A8; if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actionFunc = func_80B42A8C; if (this->actor.textId == 0xC2D) { - func_80B40BC0(this, 1); + EnKgy_ChangeAnimLoopMorph(this, ENKGY_ANIM_1); } else { - EnKgy_ChangeAnim(this, 5, ANIMMODE_ONCE, -5.0f); + EnKgy_ChangeAnim(this, ENKGY_ANIM_5, ANIMMODE_ONCE, -5.0f); SET_WEEKEVENTREG(WEEKEVENTREG_20_80); } func_80B411DC(this, play, 0); @@ -1065,7 +1116,7 @@ void func_80B42D28(EnKgy* this, PlayState* play) { this->actionFunc = func_80B4296C; SET_WEEKEVENTREG(WEEKEVENTREG_21_01); } else if (this->actor.xzDistToPlayer < 200.0f) { - if (this->unk_2D2 == 4) { + if (this->animIndex == ENKGY_ANIM_4) { this->actor.textId = 0xC2D; } else { this->actor.textId = 0xC1D; @@ -1073,8 +1124,8 @@ void func_80B42D28(EnKgy* this, PlayState* play) { Actor_OfferTalk(&this->actor, play, 210.0f); } - if ((this->unk_2D2 == 0) && (this->actor.xzDistToPlayer < 200.0f)) { - EnKgy_ChangeAnim(this, 8, ANIMMODE_ONCE, 5.0f); + if ((this->animIndex == ENKGY_ANIM_0) && (this->actor.xzDistToPlayer < 200.0f)) { + EnKgy_ChangeAnim(this, ENKGY_ANIM_8, ANIMMODE_ONCE, 5.0f); } } } @@ -1085,7 +1136,7 @@ void EnKgy_Update(Actor* thisx, PlayState* play) { Vec3s sp30; this->actionFunc(this, play); - if (this->unk_2D2 == 2) { + if (this->animIndex == ENKGY_ANIM_2) { sp30.z = 0; sp30.y = 0; sp30.x = 0; @@ -1100,14 +1151,14 @@ s32 EnKgy_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p EnKgy* this = THIS; if (!(this->unk_29C & 1)) { - if (limbIndex == 17) { + if (limbIndex == OBJECT_KGY_LIMB_11) { *dList = NULL; } - } else if (limbIndex == 16) { + } else if (limbIndex == OBJECT_KGY_LIMB_10) { *dList = NULL; } - if (limbIndex == 11) { + if (limbIndex == OBJECT_KGY_LIMB_0B) { rot->x += this->unk_2CC.y; } @@ -1119,11 +1170,11 @@ void EnKgy_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, static Vec3f D_80B432E4 = { 3000.0f, 4000.0f, 300.0f }; EnKgy* this = THIS; - if (limbIndex == 11) { + if (limbIndex == OBJECT_KGY_LIMB_0B) { Matrix_MultVec3f(&D_80B432D8, &this->unk_2A8); } - if (limbIndex == 16) { + if (limbIndex == OBJECT_KGY_LIMB_10) { Matrix_MultVec3f(&D_80B432E4, &this->unk_2C0); } } diff --git a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.h b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.h index 94f2aabd5..9a037ba9e 100644 --- a/src/overlays/actors/ovl_En_Kgy/z_en_kgy.h +++ b/src/overlays/actors/ovl_En_Kgy/z_en_kgy.h @@ -2,6 +2,7 @@ #define Z_EN_KGY_H #include "global.h" +#include "objects/object_kgy/object_kgy.h" #include "overlays/actors/ovl_En_Kbt/z_en_kbt.h" #include "overlays/actors/ovl_Obj_Ice_Poly/z_obj_ice_poly.h" @@ -15,8 +16,8 @@ typedef void (*EnKgyActionFunc)(struct EnKgy*, PlayState*); typedef struct EnKgy { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s jointTable[23]; - /* 0x212 */ Vec3s morphTable[23]; + /* 0x188 */ Vec3s jointTable[OBJECT_KGY_LIMB_MAX]; + /* 0x212 */ Vec3s morphTable[OBJECT_KGY_LIMB_MAX]; /* 0x29C */ u16 unk_29C; /* 0x2A0 */ EnKbt* zubora; /* 0x2A4 */ ObjIcePoly* iceBlock; @@ -24,10 +25,10 @@ typedef struct EnKgy { /* 0x2B4 */ Vec3f unk_2B4; /* 0x2C0 */ Vec3f unk_2C0; /* 0x2CC */ Vec3s unk_2CC; - /* 0x2D2 */ s16 unk_2D2; + /* 0x2D2 */ s16 animIndex; /* 0x2D4 */ s16 csIdList[6]; /* 0x2E0 */ s16 csIdIndex; - /* 0x2E2 */ s16 unk_2E2; + /* 0x2E2 */ s16 animIndex2; /* 0x2E4 */ s16 unk_2E4; /* 0x2E6 */ s16 unk_2E6; /* 0x2E8 */ s16 unk_2E8; diff --git a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c index beb994374..24fa855c5 100644 --- a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c +++ b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c @@ -173,6 +173,9 @@ void EnKujiya_ChooseNextDialogue(EnKujiya* this, PlayState* play) { EnKujiya_SetupGivePrize(this); EnKujiya_GivePrize(this, play); break; + + default: + break; } } } @@ -207,6 +210,9 @@ void EnKujiya_Talk(EnKujiya* this, PlayState* play) { this->textId = 0x2B60; // Will announce winning numbers after 6 } break; + + default: + break; } } @@ -251,6 +257,9 @@ s32 EnKujiya_CheckBoughtTicket(void) { return true; } break; + + default: + break; } return false; } @@ -268,6 +277,9 @@ void EnKujiya_SetBoughtTicket(void) { case 3: SET_WEEKEVENTREG(WEEKEVENTREG_33_40); break; + + default: + break; } } @@ -287,6 +299,9 @@ void EnKujiya_UnsetBoughtTicket(void) { case 3: CLEAR_WEEKEVENTREG(WEEKEVENTREG_33_40); break; + + default: + break; } } diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c index 8bbbaca14..890fafd37 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -571,6 +571,9 @@ void EnKusa_Fall(EnKusa* this, PlayState* play) { EnKusa_SetupUprootedWaitRegrow(this); this->actor.shape.shadowDraw = NULL; break; + + default: + break; } } else { @@ -621,9 +624,13 @@ void EnKusa_SetupCut(EnKusa* this) { case ENKUSA_TYPE_GRASS_2: this->actionFunc = EnKusa_DoNothing; break; + case ENKUSA_TYPE_REGROWING_GRASS: this->actionFunc = EnKusa_CutWaitRegrow; break; + + default: + break; } this->timer = 0; } diff --git a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c index 5dc86c745..cbd94d808 100644 --- a/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c +++ b/src/overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.c @@ -248,7 +248,8 @@ void ObjSyokudai_Update(Actor* thisx, PlayState* play2) { this->snuffTimer = OBJ_SYOKUDAI_SNUFF_NEVER; } } else { - if (++sNumLitTorchesInGroup >= groupSize) { + sNumLitTorchesInGroup++; + if (sNumLitTorchesInGroup >= groupSize) { this->pendingAction = OBJ_SYOKUDAI_PENDING_ACTION_CUTSCENE_AND_SWITCH; } else { this->snuffTimer = diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 83c871191..fbdcd2791 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -13493,7 +13493,7 @@ 0x80B33E54:("EnKbt_Destroy",), 0x80B33E64:("func_80B33E64",), 0x80B33E8C:("func_80B33E8C",), - 0x80B33EF0:("func_80B33EF0",), + 0x80B33EF0:("EnKbt_ChangeAnim",), 0x80B3403C:("func_80B3403C",), 0x80B34078:("func_80B34078",), 0x80B3415C:("func_80B3415C",), @@ -13678,7 +13678,7 @@ 0x80B40800:("EnKgy_Init",), 0x80B40B04:("EnKgy_Destroy",), 0x80B40B38:("func_80B40B38",), - 0x80B40BC0:("func_80B40BC0",), + 0x80B40BC0:("EnKgy_ChangeAnimLoopMorph",), 0x80B40BFC:("func_80B40BFC",), 0x80B40C38:("func_80B40C38",), 0x80B40C74:("func_80B40C74",), From 2a485ad774d10ce5225dc8e119c0879108c78740 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Sun, 1 Oct 2023 17:12:09 +1100 Subject: [PATCH 9/9] Animation Cleanup: En_J* (#1401) * cleanup J * small fix --- src/overlays/actors/ovl_En_Ja/z_en_ja.c | 107 +++++++++++------- src/overlays/actors/ovl_En_Ja/z_en_ja.h | 9 +- .../actors/ovl_En_Jc_Mato/z_en_jc_mato.c | 2 +- src/overlays/actors/ovl_En_Jg/z_en_jg.c | 107 +++++++++--------- .../actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c | 48 +++++--- src/overlays/actors/ovl_En_Js/z_en_js.c | 76 +++++++++++-- .../actors/ovl_En_S_Goro/z_en_s_goro.c | 97 +++++++++------- tools/disasm/functions.txt | 4 +- 8 files changed, 281 insertions(+), 169 deletions(-) diff --git a/src/overlays/actors/ovl_En_Ja/z_en_ja.c b/src/overlays/actors/ovl_En_Ja/z_en_ja.c index 8cf9ce0e9..6bf6b4434 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -5,7 +5,6 @@ */ #include "z_en_ja.h" -#include "objects/object_boj/object_boj.h" #define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_FRIENDLY | ACTOR_FLAG_10) @@ -89,27 +88,41 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static AnimationInfoS sAnimationInfo[] = { - { &object_boj_Anim_002734, 1.0f, 0, -1, 0, 0 }, { &object_boj_Anim_0033B0, 1.0f, 0, -1, 0, 0 }, - { &object_boj_Anim_002734, 1.0f, 0, -1, 0, -4 }, { &object_boj_Anim_0033B0, 1.0f, 0, -1, 0, -4 }, - { &object_boj_Anim_004078, 1.0f, 0, -1, 0, 0 }, { &object_boj_Anim_005CE4, 1.0f, 0, -1, 0, 0 }, +typedef enum EnJaAnimation { + /* -1 */ ENJA_ANIM_NONE = -1, + /* 0 */ ENJA_ANIM_0, + /* 1 */ ENJA_ANIM_1, + /* 2 */ ENJA_ANIM_2, + /* 3 */ ENJA_ANIM_3, + /* 4 */ ENJA_ANIM_4, + /* 5 */ ENJA_ANIM_5, + /* 6 */ ENJA_ANIM_MAX +} EnJaAnimation; + +static AnimationInfoS sAnimationInfo[ENJA_ANIM_MAX] = { + { &object_boj_Anim_002734, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENJA_ANIM_0 + { &object_boj_Anim_0033B0, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENJA_ANIM_1 + { &object_boj_Anim_002734, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENJA_ANIM_2 + { &object_boj_Anim_0033B0, 1.0f, 0, -1, ANIMMODE_LOOP, -4 }, // ENJA_ANIM_3 + { &object_boj_Anim_004078, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENJA_ANIM_4 + { &object_boj_Anim_005CE4, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // ENJA_ANIM_5 }; -void func_80BC1900(EnJa* this) { - this->skelAnime.playSpeed = this->unk_344; +void EnJa_UpdateSkelAnime(EnJa* this) { + this->skelAnime.playSpeed = this->animPlaySpeed; SkelAnime_Update(&this->skelAnime); } -s32 func_80BC192C(EnJa* this, s32 arg1) { - s32 ret = false; +s32 EnJa_ChangeAnim(EnJa* this, s32 animIndex) { + s32 didAnimChange = false; - if (arg1 != this->unk_36C) { - this->unk_36C = arg1; - ret = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, arg1); - this->unk_344 = this->skelAnime.playSpeed; + if (this->animIndex != animIndex) { + this->animIndex = animIndex; + didAnimChange = SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, animIndex); + this->animPlaySpeed = this->skelAnime.playSpeed; } - return ret; + return didAnimChange; } void func_80BC1984(EnJa* this, PlayState* play) { @@ -246,7 +259,7 @@ s32 func_80BC1FC8(EnJa* this, PlayState* play, ScheduleOutput* scheduleOutput) { if (func_80BC1AE0(this, play)) { SubS_SetOfferMode(&this->unk_340, SUBS_OFFER_MODE_ONSCREEN, SUBS_OFFER_MODE_MASK); this->unk_340 |= 0x10; - func_80BC192C(this, 5); + EnJa_ChangeAnim(this, ENJA_ANIM_5); func_80BC2EA4(this); ret = true; } @@ -258,9 +271,9 @@ s32 func_80BC203C(EnJa* this, PlayState* play, ScheduleOutput* scheduleOutput) { if (func_80BC1AE0(this, play)) { if (ENJA_GET_3(&this->actor) == 0) { - func_80BC192C(this, 1); + EnJa_ChangeAnim(this, ENJA_ANIM_1); } else { - func_80BC192C(this, 4); + EnJa_ChangeAnim(this, ENJA_ANIM_4); } SubS_SetOfferMode(&this->unk_340, SUBS_OFFER_MODE_ONSCREEN, SUBS_OFFER_MODE_MASK); this->actor.shape.shadowDraw = NULL; @@ -284,6 +297,9 @@ s32 func_80BC20D0(EnJa* this, PlayState* play, ScheduleOutput* scheduleOutput) { case 2: ret = func_80BC203C(this, play, scheduleOutput); break; + + default: + break; } return ret; } @@ -329,8 +345,10 @@ s32* func_80BC2274(EnJa* this, PlayState* play) { return D_80BC362C; } return D_80BC366C; + + default: + return D_80BC360C; } - return D_80BC360C; } void func_80BC22F4(EnJa* this, PlayState* play) { @@ -348,9 +366,10 @@ void EnJa_Init(Actor* thisx, PlayState* play) { EnJa* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 18.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &object_boj_Skel_00C240, NULL, this->jointTable, this->morphTable, 16); - this->unk_36C = -1; - func_80BC192C(this, 0); + SkelAnime_InitFlex(play, &this->skelAnime, &object_boj_Skel_00C240, NULL, this->jointTable, this->morphTable, + OBJECT_BOJ_LIMB_MAX); + this->animIndex = ENJA_ANIM_NONE; + EnJa_ChangeAnim(this, ENJA_ANIM_0); Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); Actor_SetScale(&this->actor, 0.01f); @@ -380,7 +399,7 @@ void EnJa_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); if (this->unk_1D8.unk_00 != 0) { - func_80BC1900(this); + EnJa_UpdateSkelAnime(this); func_80BC1A68(this); func_80BC1D70(this, play); @@ -403,7 +422,7 @@ void EnJa_Update(Actor* thisx, PlayState* play) { s32 EnJa_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnJa* this = THIS; - if (limbIndex == 15) { + if (limbIndex == OBJECT_BOJ_LIMB_0F) { func_80BC1E40(this, play); } return false; @@ -419,10 +438,10 @@ void EnJa_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, EnJa* this = THIS; s32 pad2; - if (limbIndex == 15) { + if (limbIndex == OBJECT_BOJ_LIMB_0F) { Matrix_MultVec3f(&D_80BC3780, &this->actor.focus.pos); Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); - } else if ((this->unk_340 & 0x40) && (limbIndex == 11)) { + } else if ((this->unk_340 & 0x40) && (limbIndex == OBJECT_BOJ_LIMB_0B)) { OPEN_DISPS(play->state.gfxCtx); Matrix_Push(); @@ -437,8 +456,9 @@ void EnJa_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, } if (this->unk_1D8.unk_00 == 1) { - if ((limbIndex == 11) && (((this->skelAnime.curFrame >= 0.0f) && (this->skelAnime.curFrame <= 6.0f)) || - ((this->skelAnime.curFrame >= 35.0f) && (this->skelAnime.curFrame <= 47.0f)))) { + if ((limbIndex == OBJECT_BOJ_LIMB_0B) && + (((this->skelAnime.curFrame >= 0.0f) && (this->skelAnime.curFrame <= 6.0f)) || + ((this->skelAnime.curFrame >= 35.0f) && (this->skelAnime.curFrame <= 47.0f)))) { OPEN_DISPS(play->state.gfxCtx); Matrix_Push(); @@ -475,7 +495,7 @@ void EnJa_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Matrix_Pop(); CLOSE_DISPS(play->state.gfxCtx); - } else if (limbIndex == 14) { + } else if (limbIndex == OBJECT_BOJ_LIMB_0E) { if ((this->skelAnime.curFrame >= 0.0f) && (this->skelAnime.curFrame <= 18.0f)) { OPEN_DISPS(play->state.gfxCtx); @@ -541,8 +561,8 @@ void EnJa_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { overrideRot = false; } - if (limbIndex != 8) { - if (limbIndex == 15) { + switch (limbIndex) { + case OBJECT_BOJ_LIMB_0F: SubS_UpdateLimb(this->unk_354 + this->unk_358 + 0x4000, this->unk_356 + this->unk_35A + this->actor.shape.rot.y + 0x4000, &this->unk_1EC, &this->unk_274, stepRot, overrideRot); @@ -553,17 +573,22 @@ void EnJa_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { Matrix_RotateXS(this->unk_274.x, MTXMODE_APPLY); Matrix_RotateZS(this->unk_274.z, MTXMODE_APPLY); Matrix_Push(); - } - } else { - SubS_UpdateLimb(this->unk_358 + 0x4000, this->unk_35A + this->actor.shape.rot.y + 0x4000, &this->unk_1F8, - &this->unk_27A, stepRot, overrideRot); - Matrix_Pop(); - Matrix_Translate(this->unk_1F8.x, this->unk_1F8.y, this->unk_1F8.z, MTXMODE_NEW); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateYS(this->unk_27A.y, MTXMODE_APPLY); - Matrix_RotateXS(this->unk_27A.x, MTXMODE_APPLY); - Matrix_RotateZS(this->unk_27A.z, MTXMODE_APPLY); - Matrix_Push(); + break; + + case OBJECT_BOJ_LIMB_08: + SubS_UpdateLimb(this->unk_358 + 0x4000, this->unk_35A + this->actor.shape.rot.y + 0x4000, &this->unk_1F8, + &this->unk_27A, stepRot, overrideRot); + Matrix_Pop(); + Matrix_Translate(this->unk_1F8.x, this->unk_1F8.y, this->unk_1F8.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->unk_27A.y, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_27A.x, MTXMODE_APPLY); + Matrix_RotateZS(this->unk_27A.z, MTXMODE_APPLY); + Matrix_Push(); + break; + + default: + break; } } diff --git a/src/overlays/actors/ovl_En_Ja/z_en_ja.h b/src/overlays/actors/ovl_En_Ja/z_en_ja.h index 00746ec63..fcbbf485f 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.h +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.h @@ -2,6 +2,7 @@ #define Z_EN_JA_H #include "global.h" +#include "objects/object_boj/object_boj.h" struct EnJa; @@ -37,10 +38,10 @@ typedef struct EnJa { /* 0x234 */ EnJaStruct unk_234[4]; /* 0x274 */ Vec3s unk_274; /* 0x27A */ Vec3s unk_27A; - /* 0x280 */ Vec3s jointTable[16]; - /* 0x2E0 */ Vec3s morphTable[16]; + /* 0x280 */ Vec3s jointTable[OBJECT_BOJ_LIMB_MAX]; + /* 0x2E0 */ Vec3s morphTable[OBJECT_BOJ_LIMB_MAX]; /* 0x340 */ u16 unk_340; - /* 0x344 */ f32 unk_344; + /* 0x344 */ f32 animPlaySpeed; /* 0x348 */ f32 unk_348; /* 0x34C */ f32 unk_34C; /* 0x350 */ UNK_TYPE1 unk350[0x4]; @@ -55,7 +56,7 @@ typedef struct EnJa { /* 0x364 */ s16 unk_364; /* 0x366 */ s16 unk_366; /* 0x368 */ void* unk_368; - /* 0x36C */ s32 unk_36C; + /* 0x36C */ s32 animIndex; /* 0x370 */ UNK_TYPE1 unk_370[4]; /* 0x374 */ s32 prevTalkState; } EnJa; // size = 0x378 diff --git a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c index 314e94d1b..c66c9a355 100644 --- a/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c +++ b/src/overlays/actors/ovl_En_Jc_Mato/z_en_jc_mato.c @@ -122,7 +122,7 @@ void EnJcMato_Init(Actor* thisx, PlayState* play) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); Collider_InitSphere(play, &this->collider); Collider_SetSphere(play, &this->collider, &this->actor, &sSphereInit); - this->collider.dim.worldSphere.radius = 0xF; + this->collider.dim.worldSphere.radius = 15; this->actor.colChkInfo.damageTable = &sDamageTable; Actor_SetScale(&this->actor, 0.008f); this->hitFlag = false; diff --git a/src/overlays/actors/ovl_En_Jg/z_en_jg.c b/src/overlays/actors/ovl_En_Jg/z_en_jg.c index 9fbd7ff85..137799af3 100644 --- a/src/overlays/actors/ovl_En_Jg/z_en_jg.c +++ b/src/overlays/actors/ovl_En_Jg/z_en_jg.c @@ -34,29 +34,6 @@ s32 EnJg_GetNextTextId(EnJg* this); s32 EnJg_GetStartingConversationTextId(EnJg* this, PlayState* play); void EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(EnJg* this, PlayState* play); -typedef enum { - /* 0 */ EN_JG_ANIM_IDLE, - /* 1 */ EN_JG_ANIM_WALK, - /* 2 */ EN_JG_ANIM_WAVING, - /* 3 */ EN_JG_ANIM_SHAKING_HEAD, - /* 4 */ EN_JG_ANIM_SURPRISE_START, - /* 5 */ EN_JG_ANIM_SURPRISE_LOOP, - /* 6 */ EN_JG_ANIM_ANGRY, - /* 7 */ EN_JG_ANIM_FROZEN_START, - /* 8 */ EN_JG_ANIM_FROZEN_LOOP, - /* 9 */ EN_JG_ANIM_WALK_2, - /* 10 */ EN_JG_ANIM_TAKING_OUT_DRUM, - /* 11 */ EN_JG_ANIM_DRUM_IDLE, - /* 12 */ EN_JG_ANIM_PLAYING_DRUM, - /* 13 */ EN_JG_ANIM_THINKING, - /* 14 */ EN_JG_ANIM_REMEMBERING, - /* 15 */ EN_JG_ANIM_STRONG_REMEMBERING, - /* 16 */ EN_JG_ANIM_DEPRESSED, - /* 17 */ EN_JG_ANIM_CUTSCENE_IDLE, - /* 18 */ EN_JG_ANIM_CRADLE, - /* 19 */ EN_JG_ANIM_MAX -} EnJgAnimation; - typedef enum { /* 0 */ EN_JG_ACTION_FIRST_THAW, /* 1 */ EN_JG_ACTION_SPAWNING, @@ -133,26 +110,49 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -static AnimationInfoS sAnimationInfo[] = { - { &gGoronElderIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, - { &gGoronElderWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, - { &gGoronElderWavingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, - { &gGoronElderHeadShakeAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, - { &gGoronElderSurpriseStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -10 }, - { &gGoronElderSurpriseLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, - { &gGoronElderAngryAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, - { &gGoronElderSurpriseStartAnim, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &gGoronElderSurpriseStartAnim, -2.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &gGoronElderWalkAnim, -1.0f, 0, -1, ANIMMODE_LOOP, -10 }, - { &gGoronElderTakeOutDrumAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &gGoronElderDrumIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &gGoronElderPlayingDrumAnim, 1.0f, 1, 44, ANIMMODE_ONCE, 0 }, - { &gGoronElderThinkingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &gGoronElderRememberingAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &gGoronElderStrongRememberingAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, - { &gGoronElderDepressedAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &gGoronElderIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, - { &gGoronElderCradleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, +typedef enum EnJgAnimation { + /* 0 */ EN_JG_ANIM_IDLE, + /* 1 */ EN_JG_ANIM_WALK, + /* 2 */ EN_JG_ANIM_WAVING, + /* 3 */ EN_JG_ANIM_SHAKING_HEAD, + /* 4 */ EN_JG_ANIM_SURPRISE_START, + /* 5 */ EN_JG_ANIM_SURPRISE_LOOP, + /* 6 */ EN_JG_ANIM_ANGRY, + /* 7 */ EN_JG_ANIM_FROZEN_START, + /* 8 */ EN_JG_ANIM_FROZEN_LOOP, + /* 9 */ EN_JG_ANIM_WALK_2, + /* 10 */ EN_JG_ANIM_TAKING_OUT_DRUM, + /* 11 */ EN_JG_ANIM_DRUM_IDLE, + /* 12 */ EN_JG_ANIM_PLAYING_DRUM, + /* 13 */ EN_JG_ANIM_THINKING, + /* 14 */ EN_JG_ANIM_REMEMBERING, + /* 15 */ EN_JG_ANIM_STRONG_REMEMBERING, + /* 16 */ EN_JG_ANIM_DEPRESSED, + /* 17 */ EN_JG_ANIM_CUTSCENE_IDLE, + /* 18 */ EN_JG_ANIM_CRADLE, + /* 19 */ EN_JG_ANIM_MAX +} EnJgAnimation; + +static AnimationInfoS sAnimationInfo[EN_JG_ANIM_MAX] = { + { &gGoronElderIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, // EN_JG_ANIM_IDLE + { &gGoronElderWalkAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, // EN_JG_ANIM_WALK + { &gGoronElderWavingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, // EN_JG_ANIM_WAVING + { &gGoronElderHeadShakeAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, // EN_JG_ANIM_SHAKING_HEAD + { &gGoronElderSurpriseStartAnim, 1.0f, 0, -1, ANIMMODE_ONCE, -10 }, // EN_JG_ANIM_SURPRISE_START + { &gGoronElderSurpriseLoopAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, // EN_JG_ANIM_SURPRISE_LOOP + { &gGoronElderAngryAnim, 1.0f, 0, -1, ANIMMODE_LOOP, -10 }, // EN_JG_ANIM_ANGRY + { &gGoronElderSurpriseStartAnim, 2.0f, 0, -1, ANIMMODE_ONCE, 0 }, // EN_JG_ANIM_FROZEN_START + { &gGoronElderSurpriseStartAnim, -2.0f, 0, -1, ANIMMODE_ONCE, 0 }, // EN_JG_ANIM_FROZEN_LOOP + { &gGoronElderWalkAnim, -1.0f, 0, -1, ANIMMODE_LOOP, -10 }, // EN_JG_ANIM_WALK_2 + { &gGoronElderTakeOutDrumAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, // EN_JG_ANIM_TAKING_OUT_DRUM + { &gGoronElderDrumIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // EN_JG_ANIM_DRUM_IDLE + { &gGoronElderPlayingDrumAnim, 1.0f, 1, 44, ANIMMODE_ONCE, 0 }, // EN_JG_ANIM_PLAYING_DRUM + { &gGoronElderThinkingAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // EN_JG_ANIM_THINKING + { &gGoronElderRememberingAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, // EN_JG_ANIM_REMEMBERING + { &gGoronElderStrongRememberingAnim, 1.0f, 0, -1, ANIMMODE_ONCE, 0 }, // EN_JG_ANIM_STRONG_REMEMBERING + { &gGoronElderDepressedAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // EN_JG_ANIM_DEPRESSED + { &gGoronElderIdleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // EN_JG_ANIM_CUTSCENE_IDLE + { &gGoronElderCradleAnim, 1.0f, 0, -1, ANIMMODE_LOOP, 0 }, // EN_JG_ANIM_CRADLE }; static Vec3f sSfxPos = { 0.0f, 0.0f, 0.0f }; @@ -340,6 +340,9 @@ void EnJg_SetupTalk(EnJg* this, PlayState* play) { SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); this->actionFunc = EnJg_Talk; break; + + default: + break; } } @@ -418,10 +421,10 @@ void EnJg_GoronShrineCheer(EnJg* this, PlayState* play) { void EnJg_AlternateTalkOrWalkInPlace(EnJg* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); + s16 endFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); if (this->animIndex == EN_JG_ANIM_SURPRISE_START) { - if (curFrame == lastFrame) { + if (curFrame == endFrame) { this->animIndex = EN_JG_ANIM_SURPRISE_LOOP; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); } @@ -473,10 +476,10 @@ void EnJg_Walk(EnJg* this, PlayState* play) { void EnJg_Talk(EnJg* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); + s16 endFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); u16 temp; - if ((this->animIndex == EN_JG_ANIM_SURPRISE_START) && (curFrame == lastFrame)) { + if ((this->animIndex == EN_JG_ANIM_SURPRISE_START) && (curFrame == endFrame)) { this->animIndex = EN_JG_ANIM_SURPRISE_LOOP; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); } @@ -543,12 +546,12 @@ void EnJg_SetupWalk(EnJg* this, PlayState* play) { void EnJg_Freeze(EnJg* this, PlayState* play) { s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); + s16 endFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); if (this->action == EN_JG_ACTION_SPAWNING) { this->action = EN_JG_ACTION_FROZEN_OR_NON_FIRST_THAW; this->freezeTimer = 1000; - this->skelAnime.curFrame = lastFrame; + this->skelAnime.curFrame = endFrame; this->icePoly = Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_ICE_POLY, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, this->actor.world.rot.x, this->actor.world.rot.y, this->actor.world.rot.z, 0xFF50); @@ -557,7 +560,7 @@ void EnJg_Freeze(EnJg* this, PlayState* play) { this->actionFunc = EnJg_FrozenIdle; } else if (this->animIndex == EN_JG_ANIM_FROZEN_START) { this->action = EN_JG_ACTION_FROZEN_OR_NON_FIRST_THAW; - if (curFrame == lastFrame) { + if (curFrame == endFrame) { this->freezeTimer = 1000; this->icePoly = Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_ICE_POLY, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, this->actor.world.rot.x, @@ -899,7 +902,7 @@ void EnJg_SpawnBreath(EnJg* this, PlayState* play) { */ void EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(EnJg* this, PlayState* play) { s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); + s16 endFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->flags |= FLAG_LOOKING_AT_PLAYER; @@ -924,7 +927,7 @@ void EnJg_CheckIfTalkingToPlayerAndHandleFreezeTimer(EnJg* this, PlayState* play } this->freezeTimer--; - if ((this->freezeTimer <= 0) && (curFrame == lastFrame)) { + if ((this->freezeTimer <= 0) && (curFrame == endFrame)) { this->animIndex = EN_JG_ANIM_FROZEN_START; SubS_ChangeAnimationByInfoS(&this->skelAnime, sAnimationInfo, this->animIndex); Audio_PlaySfx_AtPos(&sSfxPos, NA_SE_EV_FREEZE_S); diff --git a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c index 013fb5050..aba7cdeeb 100644 --- a/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c +++ b/src/overlays/actors/ovl_En_Jgame_Tsn/z_en_jgame_tsn.c @@ -48,10 +48,18 @@ ActorInit En_Jgame_Tsn_InitVars = { (ActorFunc)EnJgameTsn_Draw, }; -static AnimationInfo sAnimationInfo[] = { - { &object_tsn_Anim_0092FC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, - { &object_tsn_Anim_000964, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, - { &object_tsn_Anim_001198, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, +typedef enum EnJgameTsnAnimation { + /* -1 */ ENJGAMETSN_ANIM_NONE = -1, + /* 0 */ ENJGAMETSN_ANIM_0, + /* 1 */ ENJGAMETSN_ANIM_1, + /* 2 */ ENJGAMETSN_ANIM_2, + /* 3 */ ENJGAMETSN_ANIM_MAX +} EnJgameTsnAnimation; + +static AnimationInfo sAnimationInfo[ENJGAMETSN_ANIM_MAX] = { + { &object_tsn_Anim_0092FC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, // ENJGAMETSN_ANIM_0 + { &object_tsn_Anim_000964, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, // ENJGAMETSN_ANIM_1 + { &object_tsn_Anim_001198, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f }, // ENJGAMETSN_ANIM_2 }; static ColliderCylinderInit sCylinderInit = { @@ -145,7 +153,7 @@ void EnJgameTsn_Destroy(Actor* thisx, PlayState* play) { } void func_80C13B74(EnJgameTsn* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENJGAMETSN_ANIM_0); this->actionFunc = func_80C13BB8; } @@ -156,15 +164,15 @@ void func_80C13BB8(EnJgameTsn* this, PlayState* play) { if (this->actor.flags & ACTOR_FLAG_10000) { this->actor.flags &= ~ACTOR_FLAG_10000; if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] > SECONDS_TO_TIMER(0)) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENJGAMETSN_ANIM_1); Message_StartTextbox(play, 0x10A2, &this->actor); this->unk_300 = 0x10A2; } else if (gSaveContext.minigameScore < 20) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENJGAMETSN_ANIM_1); Message_StartTextbox(play, 0x10A2, &this->actor); this->unk_300 = 0x10A2; } else { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENJGAMETSN_ANIM_2); Message_StartTextbox(play, 0x10A3, &this->actor); this->unk_300 = 0x10A3; } @@ -174,11 +182,11 @@ void func_80C13BB8(EnJgameTsn* this, PlayState* play) { this->unk_300 = 0x1094; } else if (this->unk_2F8 == 0) { this->unk_2F8 = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENJGAMETSN_ANIM_1); Message_StartTextbox(play, 0x1095, &this->actor); this->unk_300 = 0x1095; } else { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENJGAMETSN_ANIM_1); Message_StartTextbox(play, 0x1096, &this->actor); this->unk_300 = 0x1096; } @@ -211,11 +219,11 @@ void func_80C13E90(EnJgameTsn* this, PlayState* play) { this->actor.flags &= ~ACTOR_FLAG_10000; if (((gSaveContext.save.time > CLOCK_TIME(4, 0)) && (gSaveContext.save.time < CLOCK_TIME(7, 0))) || ((gSaveContext.save.time > CLOCK_TIME(16, 0)) && (gSaveContext.save.time < CLOCK_TIME(19, 0)))) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENJGAMETSN_ANIM_2); Message_StartTextbox(play, 0x1094, &this->actor); this->unk_300 = 0x1094; } else { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENJGAMETSN_ANIM_1); Message_StartTextbox(play, 0x1098, &this->actor); this->unk_300 = 0x1098; } @@ -273,6 +281,9 @@ void func_80C14044(EnJgameTsn* this, PlayState* play) { func_80C13B74(this); } break; + + default: + break; } Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 0x71C, 0xB6); @@ -335,7 +346,7 @@ void func_80C14230(EnJgameTsn* this, PlayState* play) { this->unk_2FC++; if ((player->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) && func_80C149B0(play, &this->unk_200)) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENJGAMETSN_ANIM_2); Message_StartTextbox(play, 0x109F, &this->actor); this->unk_300 = 0x109F; player->stateFlags1 |= PLAYER_STATE1_20; @@ -344,7 +355,7 @@ void func_80C14230(EnJgameTsn* this, PlayState* play) { func_80C14030(this); } else if ((player->actor.bgCheckFlags & BGCHECKFLAG_WATER_TOUCH) || (player->actor.bgCheckFlags & BGCHECKFLAG_WATER)) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENJGAMETSN_ANIM_2); Message_StartTextbox(play, 0x10A0, &this->actor); this->unk_300 = 0x10A0; player->stateFlags1 |= PLAYER_STATE1_20; @@ -413,12 +424,12 @@ void func_80C14684(EnJgameTsn* this, PlayState* play) { this->unk_300 = 0x109E; Rupees_ChangeBy(-20); } else { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENJGAMETSN_ANIM_2); Message_StartTextbox(play, 0x109D, &this->actor); this->unk_300 = 0x109D; } } else { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENJGAMETSN_ANIM_2); Message_StartTextbox(play, 0x109C, &this->actor); this->unk_300 = 0x109C; } @@ -461,7 +472,7 @@ void func_80C147B4(EnJgameTsn* this, PlayState* play) { break; case 0x109A: - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, ENJGAMETSN_ANIM_0); Message_StartTextbox(play, 0x109B, &this->actor); this->unk_300 = 0x109B; break; @@ -490,6 +501,9 @@ void func_80C147B4(EnJgameTsn* this, PlayState* play) { func_80C14540(this); func_80C14554(this, play); break; + + default: + break; } } } diff --git a/src/overlays/actors/ovl_En_Js/z_en_js.c b/src/overlays/actors/ovl_En_Js/z_en_js.c index c0f5bc3fd..7d5185935 100644 --- a/src/overlays/actors/ovl_En_Js/z_en_js.c +++ b/src/overlays/actors/ovl_En_Js/z_en_js.c @@ -117,6 +117,7 @@ void EnJs_Init(Actor* thisx, PlayState* play) { CLEAR_WEEKEVENTREG(WEEKEVENTREG_84_20); } break; + case 1: case 2: case 3: @@ -130,6 +131,7 @@ void EnJs_Init(Actor* thisx, PlayState* play) { return; } break; + case 5: case 6: case 7: @@ -137,6 +139,7 @@ void EnJs_Init(Actor* thisx, PlayState* play) { this->maskType = ENJS_GET_TYPE(&this->actor) - 4; this->actionFunc = func_8096A104; break; + default: break; } @@ -153,6 +156,7 @@ void EnJs_Destroy(Actor* thisx, PlayState* play) { case 0: Play_DisableMotionBlur(); break; + case 5: case 6: case 7: @@ -161,6 +165,7 @@ void EnJs_Destroy(Actor* thisx, PlayState* play) { func_80969400(ENJS_GET_TYPE(&this->actor)); } break; + default: break; } @@ -414,6 +419,7 @@ s32 func_809692A8(s32 arg0) { return false; } return true; + case 5: case 6: case 7: @@ -422,6 +428,7 @@ s32 func_809692A8(s32 arg0) { return false; } return true; + default: return false; } @@ -441,6 +448,7 @@ s32 func_8096933C(s32 arg0) { } else { return true; } + case 5: case 6: case 7: @@ -451,6 +459,7 @@ s32 func_8096933C(s32 arg0) { } else { return true; } + default: return false; } @@ -579,13 +588,18 @@ void func_80969898(EnJs* this, PlayState* play) { Audio_PlaySfx_MessageDecide(); Message_ContinueTextbox(play, 0x2217); break; + case 1: Audio_PlaySfx_MessageCancel(); Message_ContinueTextbox(play, 0x2216); break; + + default: + break; } } break; + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { @@ -593,18 +607,21 @@ void func_80969898(EnJs* this, PlayState* play) { this->unk_2B8 |= 1; if (!func_8096933C(ENJS_GET_TYPE(&this->actor))) { Message_ContinueTextbox(play, 0x220F); - break; + } else { + Message_ContinueTextbox(play, 0x220D); } - Message_ContinueTextbox(play, 0x220D); break; + case 0x220D: case 0x2213: Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; + case 0x220E: Message_ContinueTextbox(play, 0xFF); this->actionFunc = func_80969748; break; + case 0x2210: case 0x2211: case 0x2212: @@ -612,19 +629,23 @@ void func_80969898(EnJs* this, PlayState* play) { Message_ContinueTextbox(play, 0xFF); this->actionFunc = func_80969748; break; + case 0x2214: case 0x2217: if (!func_809695FC(this, play)) { func_80969494(this, play); - break; } break; + default: func_80969494(this, play); break; } } break; + + default: + break; } } @@ -729,13 +750,16 @@ void func_80969DA4(EnJs* this, PlayState* play) { Audio_PlaySfx_MessageDecide(); if (!func_809695FC(this, play)) { func_809694E8(this, play); - break; } break; + case 1: Audio_PlaySfx_MessageCancel(); Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; + + default: + break; } } break; @@ -745,49 +769,60 @@ void func_80969DA4(EnJs* this, PlayState* play) { case 0x221B: if (!func_8096933C(ENJS_GET_TYPE(&this->actor))) { Message_ContinueTextbox(play, 0x2219); - break; + } else { + Message_ContinueTextbox(play, 0x221C); } - Message_ContinueTextbox(play, 0x221C); break; + case 0x2224: case 0x2226: case 0x2228: case 0x222A: Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; + case 0x2225: case 0x2227: case 0x2229: case 0x222B: if (!func_809695FC(this, play)) { func_809694E8(this, play); - break; } break; + case 0x2222: player->exchangeItemAction = PLAYER_IA_NONE; Message_ContinueTextbox(play, play->msgCtx.currentTextId + 1); break; + case 0x2223: switch (ENJS_GET_TYPE(&this->actor)) { case 5: Message_ContinueTextbox(play, 0x2224); break; + case 6: Message_ContinueTextbox(play, 0x2226); break; + case 7: Message_ContinueTextbox(play, 0x2228); break; + case 8: Message_ContinueTextbox(play, 0x222A); break; + + default: + break; } break; + case 0x221C: Message_ContinueTextbox(play, 0xFF); this->actionFunc = func_80969C54; break; + case 0x221D: case 0x2220: case 0x2221: @@ -795,12 +830,16 @@ void func_80969DA4(EnJs* this, PlayState* play) { Message_ContinueTextbox(play, 0xFF); this->actionFunc = func_80969C54; break; + default: func_809694E8(this, play); break; } } break; + + default: + break; } } @@ -892,6 +931,9 @@ void func_8096A38C(EnJs* this, PlayState* play) { case 1: Audio_PlaySfx_MessageCancel(); break; + + default: + break; } switch (play->msgCtx.currentTextId) { @@ -902,9 +944,13 @@ void func_8096A38C(EnJs* this, PlayState* play) { Animation_MorphToPlayOnce(&this->skelAnime, &gMoonChildGettingUpAnim, -5.0f); this->unk_2B8 |= 0x10; break; + case 1: Message_ContinueTextbox(play, 0x21FD); break; + + default: + break; } break; @@ -914,9 +960,13 @@ void func_8096A38C(EnJs* this, PlayState* play) { Message_ContinueTextbox(play, 0x2200); func_809696EC(this, 0); break; + case 1: Message_ContinueTextbox(play, 0x21FF); break; + + default: + break; } break; @@ -927,13 +977,21 @@ void func_8096A38C(EnJs* this, PlayState* play) { Animation_MorphToPlayOnce(&this->skelAnime, &gMoonChildGettingUpAnim, -5.0f); this->unk_2B8 |= 0x10; break; + case 1: Message_ContinueTextbox(play, 0x2204); break; + + default: + break; } + + default: + break; } } break; + case TEXT_STATE_5: if (Message_ShouldAdvance(play)) { switch (play->msgCtx.currentTextId) { @@ -962,7 +1020,6 @@ void func_8096A38C(EnJs* this, PlayState* play) { break; case 0x2201: - case 0x220A: if (!func_809695FC(this, play)) { func_80969530(this, play); @@ -975,6 +1032,9 @@ void func_8096A38C(EnJs* this, PlayState* play) { } } break; + + default: + break; } } diff --git a/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c b/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c index 6b2e06f0b..3e3ecc621 100644 --- a/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c +++ b/src/overlays/actors/ovl_En_S_Goro/z_en_s_goro.c @@ -1381,53 +1381,62 @@ void EnSGoro_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { s32 overrideRot; EnSGoro* this = THIS; - if (limbIndex != GORON_LIMB_BODY) { - if ((limbIndex == GORON_LIMB_HEAD) && (this->animInfoIndex != EN_S_GORO_ANIM_SLEEPY)) { - if (this->actionFlags & EN_S_GORO_ACTIONFLAG_FACEPLAYER) { - overrideRot = true; - } else { - overrideRot = false; + switch (limbIndex) { + case GORON_LIMB_HEAD: + if (this->animInfoIndex != EN_S_GORO_ANIM_SLEEPY) { + if (this->actionFlags & EN_S_GORO_ACTIONFLAG_FACEPLAYER) { + overrideRot = true; + } else { + overrideRot = false; + } + if (this->loseAttentionTimer != 0) { + stepRot = true; + } else { + stepRot = false; + } + + EnSGoro_UpdateLimb(this->headRotZ + this->bodyRotZ + 0x4000, + this->headRotY + this->bodyRotY + this->actor.shape.rot.y + 0x4000, + &this->headTranslate, &this->headRotate, stepRot, overrideRot); + + Matrix_Pop(); + Matrix_Translate(this->headTranslate.x, this->headTranslate.y, this->headTranslate.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->headRotate.y, MTXMODE_APPLY); + Matrix_RotateXS(this->headRotate.x, MTXMODE_APPLY); + Matrix_RotateZS(this->headRotate.z, MTXMODE_APPLY); + Matrix_Push(); } - if (this->loseAttentionTimer != 0) { - stepRot = true; - } else { - stepRot = false; + break; + + case GORON_LIMB_BODY: + if (this->animInfoIndex != EN_S_GORO_ANIM_SLEEPY) { + if (this->actionFlags & EN_S_GORO_ACTIONFLAG_FACEPLAYER) { + overrideRot = true; + } else { + overrideRot = false; + } + if (this->loseAttentionTimer != 0) { + stepRot = true; + } else { + stepRot = false; + } + + EnSGoro_UpdateLimb(this->bodyRotZ + 0x4000, this->bodyRotY + this->actor.shape.rot.y + 0x4000, + &this->bodyTranslate, &this->bodyRotate, stepRot, overrideRot); + + Matrix_Pop(); + Matrix_Translate(this->bodyTranslate.x, this->bodyTranslate.y, this->bodyTranslate.z, MTXMODE_NEW); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateYS(this->bodyRotate.y, MTXMODE_APPLY); + Matrix_RotateXS(this->bodyRotate.x, MTXMODE_APPLY); + Matrix_RotateZS(this->bodyRotate.z, MTXMODE_APPLY); + Matrix_Push(); } + break; - EnSGoro_UpdateLimb(this->headRotZ + this->bodyRotZ + 0x4000, - this->headRotY + this->bodyRotY + this->actor.shape.rot.y + 0x4000, &this->headTranslate, - &this->headRotate, stepRot, overrideRot); - - Matrix_Pop(); - Matrix_Translate(this->headTranslate.x, this->headTranslate.y, this->headTranslate.z, MTXMODE_NEW); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateYS(this->headRotate.y, MTXMODE_APPLY); - Matrix_RotateXS(this->headRotate.x, MTXMODE_APPLY); - Matrix_RotateZS(this->headRotate.z, MTXMODE_APPLY); - Matrix_Push(); - } - } else if (this->animInfoIndex != EN_S_GORO_ANIM_SLEEPY) { - if (this->actionFlags & EN_S_GORO_ACTIONFLAG_FACEPLAYER) { - overrideRot = true; - } else { - overrideRot = false; - } - if (this->loseAttentionTimer != 0) { - stepRot = true; - } else { - stepRot = false; - } - - EnSGoro_UpdateLimb(this->bodyRotZ + 0x4000, this->bodyRotY + this->actor.shape.rot.y + 0x4000, - &this->bodyTranslate, &this->bodyRotate, stepRot, overrideRot); - - Matrix_Pop(); - Matrix_Translate(this->bodyTranslate.x, this->bodyTranslate.y, this->bodyTranslate.z, MTXMODE_NEW); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - Matrix_RotateYS(this->bodyRotate.y, MTXMODE_APPLY); - Matrix_RotateXS(this->bodyRotate.x, MTXMODE_APPLY); - Matrix_RotateZS(this->bodyRotate.z, MTXMODE_APPLY); - Matrix_Push(); + default: + break; } } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index fbdcd2791..4a8419dc5 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -15482,8 +15482,8 @@ 0x80BC11B4:("EnNb_PostLimbDraw",), 0x80BC1278:("EnNb_TransformLimbDraw",), 0x80BC1374:("EnNb_Draw",), - 0x80BC1900:("func_80BC1900",), - 0x80BC192C:("func_80BC192C",), + 0x80BC1900:("EnJa_UpdateSkelAnime",), + 0x80BC192C:("EnJa_ChangeAnim",), 0x80BC1984:("func_80BC1984",), 0x80BC19FC:("func_80BC19FC",), 0x80BC1A68:("func_80BC1A68",),